yehia Posted April 15, 2009 Posted April 15, 2009 after some testing and with ICL returning unendless errors im trying to extract an exe's icon to an icon file thats where i got so far but for a reason it creates an empty file if u have any other ways plz post them thanks for the help #include <GDIPlus.au3> $filename = @ScriptDir & "\f.exe" $iconnumber = 0 ; ;; $Ret = DllCall("shell32","long","ExtractAssociatedIcon","int",0,"str",$filename,"int*",$iconnumber) $hIcon = $Ret[0] _GDIPlus_Startup() $pBitmap = DllCall($ghGDIPDll,"int","GdipCreateBitmapFromHICON", "ptr",$hIcon, "int*",0) $pBitmap = $pBitmap[2] $CLSID = _GDIPlus_EncodersGetCLSID("ICO") _GDIPlus_ImageSaveToFileEx($pBitmap, @ScriptDir & "\cool.ico", $CLSID) _GDIPlus_ImageDispose($pBitmap) _GDIPlus_Shutdown() _WinAPI_DestroyIcon($Ret[0]) My Scripts:IE New UDFsElastic images moving under mouse (with a happy valentine's example)_FileRemoveLine
monoceres Posted April 15, 2009 Posted April 15, 2009 GDI+ can't save to icon files.After some extensive googling, I found these links, which should provide the answer, I think.http://msdn.microsoft.com/en-us/library/ms997538.aspxhttp://www.experts-exchange.com/Programmin...Q_10178834.htmlhttp://www.experts-exchange.com/Programmin...Q_20658160.htmlIf you didn't know, expert exchange's answers can be read just by scrolling down.. Broken link? PM me and I'll send you the file!
yehia Posted April 15, 2009 Author Posted April 15, 2009 thanks for the fast replay monoceres i dont have an expert exchange account ... the point im missing is i can get the icon with this call : DllCall("shell32","long","ExtractAssociatedIcon","int",0,"str",$filename,"int*",$iconnumber) but saving it to an ico file thats my problem btw i already saw the msdn page My Scripts:IE New UDFsElastic images moving under mouse (with a happy valentine's example)_FileRemoveLine
CodyBarrett Posted April 15, 2009 Posted April 15, 2009 im not very experienced with DLLs or GDI+.. or WINAPI... but COULD THIS WORK? $x=DllCall("shell32","long","ExtractAssociatedIcon","int",0,"str",$filename,"int*",$iconnumber) lol... would the variable get the STATUS of it? or the icon.. [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size]
monoceres Posted April 15, 2009 Posted April 15, 2009 i dont have an expert exchange account ...Just scroll down the page, all the way down. You don't need an account..but saving it to an ico file thats my problem btw i already saw the msdn pageI think the EE links takes care on that. Broken link? PM me and I'll send you the file!
yehia Posted April 15, 2009 Author Posted April 15, 2009 (edited) thanks for responding again "View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done." and nothing else in the page i did a work around and it wasnt a total failure #include <GDIPlus.au3> #include <IconChooser.au3> $Icon = _ChooseIcon() If $Icon[0] = "" Then Exit MsgBox(0, 'Exit', "No Icon chosen") $Ret = DllCall("shell32","long","ExtractAssociatedIcon","int",0,"str",$Icon[0],"int*",(-1*$Icon[1])-1) $hIcon = $Ret[0] _GDIPlus_Startup() $pBitmap = DllCall($ghGDIPDll,"int","GdipCreateBitmapFromHICON", "ptr",$hIcon, "int*",0) $pBitmap = $pBitmap[2] _GDIPlus_ImageSaveToFile($pBitmap,"D:\Test.png") _GDIPlus_ImageDispose($pBitmap) _GDIPlus_Shutdown() _WinAPI_DestroyIcon($Ret[0]) and after creating the png i used another function to convert it to ico but the icon was like pixeled and looking ugly ... Edited April 15, 2009 by yehia My Scripts:IE New UDFsElastic images moving under mouse (with a happy valentine's example)_FileRemoveLine
Vier Posted February 22, 2010 Posted February 22, 2010 (edited) Hey everybody, I have the same problem and found the solution with this function : Func _ExtractIconFromExe($source,$outsource,$iconnumber = 0) $Ret = DllCall("shell32","long","ExtractAssociatedIcon","int",0,"str",$source,"int*",$iconnumber) $hIcon = $Ret[0] _GDIPlus_Startup() $pBitmapdll = DllCall($ghGDIPDll,"int","GdipCreateBitmapFromHICON", "ptr",$hIcon, "int*",0) $pBitmap = $pBitmapdll[2] _WinAPI_DestroyIcon($Ret[0]) _GDIPlus_ImageSaveToFileEx($pBitmap,$outsource, "{557CF400-1A04-11D3-9A73-0000F81EF32E}") _GDIPlus_ImageDispose($pBitmap) _GDIPlus_Shutdown() Endfunc You choose icon number if you want ! Edited February 22, 2010 by Vier
BBrian Posted February 28, 2010 Posted February 28, 2010 Hey everybody, I have the same problem and found the solution with this function : Func _ExtractIconFromExe($source,$outsource,$iconnumber = 0) $Ret = DllCall("shell32","long","ExtractAssociatedIcon","int",0,"str",$source,"int*",$iconnumber) $hIcon = $Ret[0] _GDIPlus_Startup() $pBitmapdll = DllCall($ghGDIPDll,"int","GdipCreateBitmapFromHICON", "ptr",$hIcon, "int*",0) $pBitmap = $pBitmapdll[2] _WinAPI_DestroyIcon($Ret[0]) _GDIPlus_ImageSaveToFileEx($pBitmap,$outsource, "{557CF400-1A04-11D3-9A73-0000F81EF32E}") _GDIPlus_ImageDispose($pBitmap) _GDIPlus_Shutdown() Endfunc You choose icon number if you want ! I tried this - exactly what I'm looking for - but it failed at $pBitmapdll. I tried declaring Local $pBitmapdll[100] but it didn't make a difference. I tested it on two .exes and on shell32.dll. D:\Brian\autoit\5.au3 (19) : ==> Subscript used with non-Array variable.: $pBitmap = $pBitmapdll[2] $pBitmap = $pBitmapdll^ ERROR The value for $pBitmapdll was 0. $hIcon has a value, so it's the DllCall that's not returning the expected array. Any ideas?
picea892 Posted February 28, 2010 Posted February 28, 2010 (edited) This Smashly script works well for me.With a little GDI+ it wouldn't be hard to tweak from a picture to an exe icon Edited February 28, 2010 by picea892
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now