Solved

Associated Icon

Posted on 2000-04-07
4
225 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
  • 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

813 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

10 Experts available now in Live!

Get 1:1 Help Now