[python-win32] Extract icon from exe files
Tim Roberts
timr at probo.com
Mon Apr 27 19:07:18 CEST 2009
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.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the python-win32
mailing list