Solved

Associated Icon

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall‚Ķ
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.

762 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

21 Experts available now in Live!

Get 1:1 Help Now