smashly Posted June 25, 2008 Share Posted June 25, 2008 (edited) Hi,After poking around at MSDN I recently worked out how to use windows api to extract an icon group from an exe or dll to an *.ico file by using LoadLibraryEX(), FindResource() (This sounds easy huh.. must admit it took me a while to work out writing the header for the extracted icon , but a bit of byte play saw me clear to getting it working successfully.)But the problem I'm having is I need to know RT_GROUP_ICON Resource Type name that's in the exe or dll before I can extract the icon.So in my efforts I thought if I can list the RT_GROUP_ICON Resource Type names that's contained in the exe or dll I can extract the icon I require without error.I'm having trouble understanding the way to use EnumResourceNames and EnumResNameProc to list the RT_GROUP_ICON names.I sort of got lost when the EnumResourceNames function required a callback function using EnumResNameProc function.If anyone could guide me a little in how to use use/translate these functions in autoit then feel free to do so.(siao your expert knowledge in this type of thing would be greatly appreciated)Links to the functions:MSDN: EnumResourceNames FunctionMSDN: EnumResNameProc FunctionCheers Edited June 25, 2008 by smashly Link to comment Share on other sites More sharing options...
Siao Posted June 25, 2008 Share Posted June 25, 2008 (edited) In its most basic form: #include <WinAPI.au3> ConsoleWrite('Enumerating - user32.dll, type=3 (RT_ICON):' & @CRLF) _ResourceEnumNames(_WinAPI_GetModuleHandle('user32.dll'), 3) ConsoleWrite('Enumerating - ntbackup.exe, type=10 (RT_RCDATA):' & @CRLF) _ResourceEnumNames('ntbackup.exe', 10) Func _ResourceEnumNames($vModule, $iType) Local $hModule = $vModule, $aRet, $fLoad = IsString($vModule), $xCB = DllCallbackRegister('___EnumResNameProc','int','int_ptr;int_ptr;int_ptr;int_ptr') If $fLoad Then $hModule = _WinAPI_LoadLibrary($vModule) $aRet = DllCall('kernel32.dll','int','EnumResourceNamesW', 'ptr',$hModule, 'int',$iType, 'ptr',DllCallbackGetPtr($xCB), 'ptr',0) DllCallbackFree($xCB) If $fLoad Then _WinAPI_FreeLibrary($hModule) EndFunc Func ___EnumResNameProc($vModule, $pType, $pName, $lParam) Local $aSize = DllCall('kernel32.dll','int','GlobalSize','ptr',$pName), $tBuf If $aSize[0] Then $tBuf = DllStructCreate('wchar[' & $aSize[0] & ']', $pName) ConsoleWrite(DllStructGetData($tBuf, 1) & @CRLF) ;string ID Else ConsoleWrite($pName & @CRLF) ;integer ID EndIf Return 1 ;continue enumeration EndFunc Edited June 25, 2008 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
smashly Posted June 25, 2008 Author Share Posted June 25, 2008 (edited) A big THANK YOU Siao. You make it look so simple once you put it like that. Damn I tried doing the same thing for hours on end and I didn't even come close to getting it right when I look at your example. Thanks again Cheers Edit: your example should be part of the WinAPI udf. Edited June 25, 2008 by smashly Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now