[python-win32] Extract icon from exe files
EISEN Nicolas
neisen at linbox.com
Mon Apr 27 17:40:48 CEST 2009
Tim Roberts wrote:
> EISEN Nicolas wrote:
>
>> I understand I will use these functions, but my problem is to found
>> how? I have difficulties to understand how use the arguments : I try
>> some combinations and it's doesn't work.
>>
>> Two big problems:
>>
>> 1 – When I read MSDN’s API for LoadIcon, How I designed which exe
>> Files I will use ? The first argument is “handle to an instance of the
>> module whose executable file contains the icon to be loaded”: How I
>> can instantiate the handle, I didn’t found any constructor.
>>
>> I think the second argument will be: win32con.|IDI_APPLICATION|
>>
>
> I believe you actually want ExtractIcon, not LoadIcon. LoadIcon is
> mostly used by an EXE or DLL that needs to fetch its own icons.
> ExtractIcon lets you specify the name of another executable.
>
> You could use LoadLibrary to load the executable, then pass that handle
> to LoadIcon, but that's probably not the best way.
>
>
>
>> But my last problem is I didn’t found the python module for
>> GetBitmapBits() function ...
>>
>
> How much looking have you done? Did you know that the PyWin32
> win32\Demos directory contains several example of programs that
> manipulate icons, including one that calls ExtractIconEx and draws the
> icon to a bitmap?
>
>
/ from win32gui import *
import win32con
listHicon = ExtractIconEx("c:\OpenOffice.exe",0)
test =
LoadImage(listHicon[0],"c:\OpenOffice.exe",0,0,0,win32con.LR_DEFAULTSIZE)
tupleIcon = GetIconInfo(test)/
To use GetIconInfo argument should be pyHandle. listHicon is array of
Hicon. LoadImage return Handle, but the last argument must be an pyHandle
(by the interpretor error)
But normally is good by this API :
http://docs.activestate.com/activepython/2.4/pywin32/win32gui.html
I use LoadImage because LoadIcon is depreacted and it return an hicon.
I doesn't have more idea ...
Thanks.
PS : the demo menu and taskbar use icon only to display it in another
module, but i want get bitmapBit of icon to send it to an inventory server.
More information about the python-win32
mailing list