Load icon from other file (Win32/VC++)


I have code that uses:

IShellLink::GetIconLocation Method

Retrieves the location (path and index) of the icon for a Shell link object.


HRESULT GetIconLocation(          LPTSTR pszIconPath,
    int cchIconPath,
    int *piIcon

to get information about the icon associated with a windows shortcut.  Given the path, and the piIcon identifier, what function is it that actually loads the icon so my program can use it?

Who is Participating?
jkrConnect With a Mentor Commented:
You'd use 'LoadIcon()', e.g.

char acIconPath [ MAX_PATH];
int nIdx = 0;
pMyShellLink->GetIconLocation  ( acIconPath, MAX_PATH, &nIdx);

HINSTANCE hMod = LoadLibrary ( acIconPath);
HICON hIcon = LoadIcon ( hMod, nIdx);

You can use IExtractIcon::Extract Method

HICON hLarge,hSmall;
Extract(szIconLoc, iIndex, &hLarge, &hSmall, 16);
helpmealotAuthor Commented:
Thanks for the tips everyone, jkr's solution is what I had in mind.  It does just what I needed.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.