I have an exe file generated with py2exe. In the setup.py I specify an icon to be embedded in the exe:
windows=[{'script': 'my_script.py','icon_resources': [(0, 'my_icon.ico')], ...
I tried loading the icon using:
hinst = win32api.GetModuleHandle(None)
hicon = win32gui.LoadImage(hinst, 0, win32con.IMAGE_ICON, 0, 0, win32con.LR_DEFAULTSIZE)
But this produces an (very unspecific) error:
pywintypes.error: (0, 'LoadImage', 'No error message is available')
If I try specifying 0 as a string
hicon = win32gui.LoadImage(hinst, '0', win32con.IMAGE_ICON, 0, 0, win32con.LR_DEFAULTSIZE)
then I get the error:
pywintypes.error: (1813, 'LoadImage', 'The specified resource type cannot be found in the image file.')
So, what's the correct method/syntax to load the icon?
Also please notice that I don't use any GUI toolkit - just the Windows API via PyWin32.