What would be the best way to extract an icon from an executable and paint it to the screen using the QPainter?<div><br></div><div>Is there anything in PyQt that would let me open say C:\Program Files\Mozilla Firefox\Firefox.exe and extract its icon? I know that you can use win32gui to extract icons and save them as a .bmp</div>


<div><br></div><div>Quick example of that would be:</div><div>import win32ui</div><div><div>import win32gui</div><div>import win32con</div><div>import win32api</div><div><br></div><div>ico_x = win32api.GetSystemMetrics(win32con.SM_CXICON)</div>


<div>ico_y = win32api.GetSystemMetrics(win32con.SM_CYICON)</div><div><br></div><div>large, small = win32gui.ExtractIconEx(&quot;C:/Program Files/Mozilla Firefox/Firefox.exe&quot;,0)</div><div>win32gui.DestroyIcon(large[0])</div>


<div><br></div><div>hdc = win32ui.CreateDCFromHandle( win32gui.GetDC(0) )</div><div>hbmp = win32ui.CreateBitmap()</div><div>hbmp.CreateCompatibleBitmap( hdc, ico_x, ico_x )</div><div>hdc = hdc.CreateCompatibleDC()</div><div>


<br></div><div>hdc.SelectObject( hbmp )</div><div>hdc.DrawIcon( (0,0), small[0] )</div><div>hbmp.SaveBitmapFile( hdc, &quot;save.bmp&quot; )</div></div><div><br></div><div>Only problem with this is it saves a bmp where I want to paint the icon using QPainter, this also does not product a transparent icon. Is there any quick way to extract the icon using PyQt?</div>