Solved

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

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

Technology Partners: 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

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…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

735 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