Link to home
Start Free TrialLog in
Avatar of Slask
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....
ASKER CERTIFIED SOLUTION
Avatar of Priyesh
Priyesh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Slask
Slask

ASKER

Great it worked. Lock the question, the points are yours...
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.