Load icon from file

I am searching through the registry and I want to load certain icons to a HICON. I found the following:

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?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You have to load the shell32.dll and 152 must be probably the ID of the ICON inside the shell32.dll if it contains the resource, i don't know, i havent tried it, but this seems logical to me.

Try this,

HMODULE hDll = ::LoadLibrary("shell32.dll") ;
HICON hIcon = ::LoadICon(hDll, MAKEINTRESOURCE(152)) ;
//Check if hIcon is valid

::FreeLibrary(hDll) ;


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SlaskAuthor Commented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.