Slask
asked on
Load icon from file
I am searching through the registry and I want to load certain icons to a HICON. I found the following:
"shell32.dll,-152"
I want to load it into a HICON, I tried:
HICON hIcon = (HICON)LoadImage (NULL, _T("shell32.dll,-152"), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
The return value is NULL. How can I load the icon?
Thanks....
"shell32.dll,-152"
I want to load it into a HICON, I tried:
HICON hIcon = (HICON)LoadImage (NULL, _T("shell32.dll,-152"), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
The return value is NULL. How can I load the icon?
Thanks....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use FindResouce to get handle to the icon and then use LoadResource
HMODULE hDll = ::LoadLibrary("shell32.dll ") ;
HRSRC hRes = FindResource( hDll, RT_ICON, _T("152"));
HICON hIcon = (HICON) LoadResource( hDll, hRes);
::FreeLibrary(hDll) ;
That should do it.
HMODULE hDll = ::LoadLibrary("shell32.dll
HRSRC hRes = FindResource( hDll, RT_ICON, _T("152"));
HICON hIcon = (HICON) LoadResource( hDll, hRes);
::FreeLibrary(hDll) ;
That should do it.
ASKER