I'm having big problems with loading an icon from other exe files. I'm trying to load the display icon from, for example winzip. This is the code I am using:
HMODULE hFile = LoadLibraryEx (_T("C:\\PROGRA~1\\WINZIP\\winzip32.exe"), NULL, LOAD_LIBRARY_AS_DATAFILE);
HRSRC hRes = FindResource(hFile, MAKEINTRESOURCE(3), RT_ICON);
HICON hIcon = (HICON) LoadResource( hFile, hRes);
The hIcon gets a handle and do NOT return NULL. Then I try to add it into a ImageList:
m_imageList.Create (16, 16, 0, 2, 2);
Add returns -1..!!
If I instead do:
HICON hIcon = LoadIcon(hFile, MAKEINTRESOURCE(2)) ;
DWORD dwError = GetLastError ();
After LoadLibraryEx, hIcon then becomes NULL and GetLastError() returns ERROR_SUCCESS.
Anybody knows why?