[python-win32] Extract icon from exe files
EISEN Nicolas
neisen at linbox.com
Tue Apr 28 11:18:46 CEST 2009
Tim Roberts wrote:
> EISEN Nicolas wrote:
>
>>>
>>>
>> / 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)
>>
>
> import pywintypes
> ph = pywintypes.HANDLE( listHicon[0] )
>
> Now you have a PyHANDLE.
>
>
>
>> 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.
>>
>
> The demo fetches the icon and then uses BitBlt to draw it to a bitmap.
> Why is that not EXACTLY what you need? That saves you all the trouble
> of trying to extract the bitmaps from the icon and manipulate them in
> somewhat to get a usable image.
>
>
My Source :
/from win32gui import *
import win32con
from pywintypes import HANDLE
listHicon = ExtractIconEx("c:\OpenOffice.exe",0)
tupleIcon = GetIconInfo (HANDLE ( listHicon[0][0] ) )
bitmapColor = tupel [4]
buffer = PyCBitmap.GetBitmapBits ( bitmapColor, 32 )
/
My last problem (I hope) is to found what to import to get PyCBitmap
class. I found it's in win32ui module but /from win32ui import */
doesn't give me the PyCBitmap class.
I want to get the picture of executable's icon, to re-use it on web site
for example.
I list all program on the pc, and I return some information. I want add
program's icon.
Thanks a lot.
More information about the python-win32
mailing list