def LoadRes exename typeres idres lang LANG_NEUTRAL hMod windll kernel

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
def LoadRes(exename, typeres, idres, lang = LANG_NEUTRAL):
hMod = windll.kernel32.LoadLibraryExW(exename, None, lang)
if not hMod: raise WinError()
hrsrc = windll.kernel32.FindResourceExW(hMod, typeres, idres, lang)
if not hrsrc: raise WinError()
hglob = windll.kernel32.LoadResource(hMod, hrsrc)
if hglob == 0: raise WinError()
windll.kernel32.LockResource.restype=POINTER(c_void_p)
res_ptr = windll.kernel32.LockResource(hglob)
if res_ptr == 0: raise WinError()
return res_ptr[0]