Solved

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

Posted on 2004-09-03
3
1,253 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now