Solved

Associated Icon

Posted on 2000-04-07
4
229 Views
Last Modified: 2010-04-10
how can i get the icon that is associated with a file/file type?

ex: txt files have the icon
 shell32.dll -152

but i dont want that text i want the HICON

NOTE: only windows API please no MFC,OWL,ect..
0
Comment
Question by:Redlord
[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
  • 2
4 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 2694677
The 152 is the INDEX of the icon from SHELL32.DLL.

See the ExtractIcon() Windows API function.

HICON ExtractIcon(
  HINSTANCE hInst,          // instance handle
  LPCTSTR lpszExeFileName,  // file name
  UINT nIconIndex           // icon index
);
0
 
LVL 3

Author Comment

by:Redlord
ID: 2696844
That would get the icon in the dll (or exe) with a specific index, NOT the icon that is acosiated with the file or file type.

what i want is a function that i can pass: "c:\windows\desktop\mytext.txt" and get back an HICON with the icon that is acosiated with txt files
the function would also have to get the first (index = 0) icon for an exe or dll and whatever icon a lnk file uses
0
 
LVL 15

Accepted Solution

by:
NickRepin earned 200 total points
ID: 2696860
SHGetFileInfo(SHGFI_ICON)
0
 
LVL 3

Author Comment

by:Redlord
ID: 2696879
Not very indepth but works for me :)
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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

687 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