Solved

Associated Icon

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

739 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