shx Posted May 20, 2008 Share Posted May 20, 2008 I'm trying to create a graphic file, by extracting an icon from an EXE in saving it as a JPEG it seems to me that the steps are as follows. • Get a handle of the icon that you wish to use. • convert that somehow into a graphic image. • Save the graphic to a file. I understand that the method to use has to do with the GDI functions. However, if someone can give me an example of the steps, the code, it would really be appreciated. Thank you The examples that I have found by searching the forum generally show how to use an icon within a GUI control. I don't see how this would work for me. Thanks again Steven Link to comment Share on other sites More sharing options...
shx Posted May 20, 2008 Author Share Posted May 20, 2008 I'm trying to create a graphic file, by extracting an icon from an EXE in saving it as a JPEG it seems to me that the steps are as follows. " Get a handle of the icon that you wish to use. " convert that somehow into a graphic image. " Save the graphic to a file. I understand that the method to use has to do with the GDI functions. However, if someone can give me an example of the steps, the code, it would really be appreciated. Thank you The examples that I have found by searching the forum generally show how to use an icon within a GUI control. I don't see how this would work for me. Thanks again Steven Link to comment Share on other sites More sharing options...
Kip Posted May 20, 2008 Share Posted May 20, 2008 eerm, give me a minute MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Nahuel Posted May 20, 2008 Share Posted May 20, 2008 You want to make an application to do that? or you want to do it just once? If you want to do it just once, you could use 'reshack.exe'. It lets you save all the icons there is in an exe. Then use some image software to convert it to jpeg, like IrfanView. Link to comment Share on other sites More sharing options...
Kip Posted May 20, 2008 Share Posted May 20, 2008 yeah, icons arent like bitmaps. Thats probably the reason why they gave them 2 different names. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
ProgAndy Posted May 20, 2008 Share Posted May 20, 2008 You can extract with GDIPlus: #include <GDIPlus.au3> #include <IconChooser.au3> ;http://www.autoit.de/index.php?page=Thread&postID=31304#post31304 $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]) ;~ MsgBox(0, "#" & $Icon[1], @error) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Kip Posted May 20, 2008 Share Posted May 20, 2008 GdipCreateBitmapFromHICONHey! That one isn't in the helpfile (Should be added, though) MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Zedna Posted May 20, 2008 Share Posted May 20, 2008 (edited) Look at nice similar example here You will nedd to use ExtracIconEx API to get icon from EXE file,search forum for examples. Edited May 20, 2008 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
ProgAndy Posted May 20, 2008 Share Posted May 20, 2008 There are some more: http://msdn.microsoft.com/en-us/library/ms533971(VS.85).aspx *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
shx Posted May 20, 2008 Author Share Posted May 20, 2008 ProgAndy, Thanks for getting back to me and your help. <IconChooser.au3> ;http://www.autoit.de/index.php?page=Thread&postID=31304#post31304 I clicked on the link but could not understand the German. Where do I get the include file? I'm kind of a newbie so please excuse if the answer is obvious. Steven Link to comment Share on other sites More sharing options...
ProgAndy Posted May 20, 2008 Share Posted May 20, 2008 The Include is in the Spoiler Click on "Anzeigen" to open it Then you can see "AutoIt-Quellcode" *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
shx Posted May 20, 2008 Author Share Posted May 20, 2008 Look at nice similar example hereThanks for your help.This also was my post. Actually there was a problem with my browser and I ended up double posting. My apologies.I don't understand where the include iconchooser.au3 is coming from.You will nedd to use ExtracIconEx API to get icon from EXE file,search forum for examples.I did look at Extracticonex and I know it is used to create an array of handles for icons. That step I understand. But I am a beginner and there is very little in the help file or the forum that take those handles and use it to save the icon as a graphic file like a jpg or png.Steven Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted May 20, 2008 Moderators Share Posted May 20, 2008 Merged topics Link to comment Share on other sites More sharing options...
shx Posted May 20, 2008 Author Share Posted May 20, 2008 The Include is in the Spoiler Click on "Anzeigen" to open it Then you can see "AutoIt-Quellcode"O.K. I got it to run. Now I need to figure out what it is doing.ProgAndy, your help is very much appreciated.I'm a beginner so maybe my next question is obvious but when the file is saved as a png the background looks black. Why is that? does it have to do with transparency?Steven Link to comment Share on other sites More sharing options...
ProgAndy Posted May 21, 2008 Share Posted May 21, 2008 (edited) My Script consists out of 2 parts. 1) <IconChooser.au3> is a Dialog to Choose the Icon in a DLL It Returns the negative Index number Starting with -1 2) ExtractAssociatedIcon loads the Icon to memory, but needs 0 based, positive Index, so I convert it ($index*(-1))-1) GdipCreateBitmapFromHICON creates a GDIplus-Bitmap out of the Icon. The Transparency SHOULD be saved, too ( works for me) Then the Image is saved with GDIplus as png, normally WITH transparecy. How do you open the png? With MSPaint? This app doesn't support transparency. Edited May 21, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
shx Posted May 22, 2008 Author Share Posted May 22, 2008 ProgAndy, Thanks for your help and the time you took to explain things. I have gotten it to work and it has helped me alot. Steven Link to comment Share on other sites More sharing options...
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