input1: pfad zu einer dll/exe-datei mit icons drin
input2: index des icons (egal ob interner index des item directories (beginnt oft bei 120, 140 oder so) oder normierter input (0,1,2,…))
output: liste aller verschieden großer bitmaps, die im icon vorkommen, in bestmöglicher qualität (png, alpha-transparenz), zur umwandlung in ein qicon.
die ressourcen:
- http://stackoverflow.com/questions/9077 ... th-pywin32
Code: Alles auswählen
icon_res = win32api.LoadResource(None, win32con.RT_ICON, 1) hicon = ctypes.windll.user32.CreateIconFromResourceEx(icon_res, len(icon_res), True, 0x00030000, 16, 16, win32con.LR_DEFAULTCOLOR)
- http://stackoverflow.com/questions/1616 ... -with-pyqt
Code: Alles auswählen
def bitmapFromHIcon(hIcon): ico_x = win32api.GetSystemMetrics(win32con.SM_CXICON) ico_y = win32api.GetSystemMetrics(win32con.SM_CYICON) hdc = win32ui.CreateDCFromHandle(win32gui.GetDC(0)) hbmp = win32ui.CreateBitmap() hbmp.CreateCompatibleBitmap(hdc, ico_x, ico_y) hdc = hdc.CreateCompatibleDC() hdc.SelectObject(hbmp) hdc.DrawIcon((0, 0), hIcon) hdc.DeleteDC() return hbmp.GetHandle() def qiconFromDll(dllpath, iconIndex): large, small = sum(win32gui.ExtractIconEx(dllpath, iconIndex), []) smallPixmap = QPixmap.fromWinHBITMAP(bitmapFromHIcon(small), 2) largePixmap = QPixmap.fromWinHBITMAP(bitmapFromHIcon(large), 2) icon = QIcon() icon.addPixmap(smallPixmap.scaled(16, 16)) icon.addPixmap(largePixmap) return icon