Solved

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

Posted on 2004-09-03
3
1,339 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

691 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