Solved

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

Posted on 2004-09-03
3
1,290 Views
Last Modified: 2008-01-09
Hello,

I have code that uses:

============
IShellLink::GetIconLocation Method

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

Syntax

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?

Thanks.
0
Comment
Question by:helpmealot
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 125 total points
ID: 11978667
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);

//...
0
 
LVL 16

Expert Comment

by:nonubik
ID: 11980619
You can use IExtractIcon::Extract Method

HICON hLarge,hSmall;
...
Extract(szIconLoc, iIndex, &hLarge, &hSmall, 16);
0
 

Author Comment

by:helpmealot
ID: 11985076
Thanks for the tips everyone, jkr's solution is what I had in mind.  It does just what I needed.
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question