Link to home
Start Free TrialLog in
Avatar of Redlord
Redlord

asked on

Associated Icon

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..
Avatar of jhance
jhance

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
);
Avatar of Redlord

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of NickRepin
NickRepin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Redlord

ASKER

Not very indepth but works for me :)