Click here to Skip to main content
Licence 
First Posted 6 Feb 2003
Views 102,199
Downloads 2,038
Bookmarked 30 times

An ShGetFileInfo Wrapper Class

By | 6 Feb 2003 | Article
A class built around the use of ShGetFileInfo() function.

Sample Image

Introduction

The CUseShGetFileInfo class is built around the use of ShGetFileInfo() function. It's a very simple class, but I think it can be usefull. You will not have to worry anymore about setting flags and it also works for names of files that do not exist. You don't need to know the full path for a certain file in order to obtain its icon, file type or its icon's index in the system's image list (both large icons and small icons). It also provides a function for obtaining a handle to the system's image list.

User functions

Use the GetFileIconIndex function to obtain the index of the file's associated icon in the system's image list.

int CUseShGetFileInfo::GetFileIconIndex( CString strFileName , BOOL bSmallIcon )

Use the GetDirIconIndex function to obtain the index of the folder's associated icon in the system's image list.

int CUseShGetFileInfo::GetDirIconIndex( BOOL bSmallIcon )

Use the GetFileIconHandle function to obtain a handle to the file's associated icon in the system's image list.

HICON CUseShGetFileInfo::GetFileIconHandle( CString strFileName, BOOL bSmallIcon )

Use the GetFolderIconHandle function to obtain a handle to the folder's associated icon in the system's image list.

HICON CUseShGetFileInfo::GetFolderIconHandle( BOOL bSmallIcon )

Use the GetFileType function to obtain a file's type (e.g. Winamp media file).

CString CUseShGetFileInfo::GetFileType( CString strFileName)

Use the GetSystemImageListHandle function to obtain a handle to the system's image list (large icons or small icons). Use this function to create a CImageList object to attach to a list control. After this image list is attached to the list control, use GetFileIconIndex or GetDirIconIndex to obtain the value to set for the nImage field (e.g. CListCtrl::InsertItem() function)

HIMAGELIST CUseShGetFileInfo::GetSystemImageListHandle( BOOL bSmallIcon )

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Doru Cioata

Web Developer

Romania Romania

Member

Still a student at a computer science related faculty in the University of Craiova, Romania :Frown | :(
Hope that one day I'll graduate! Smile | :) ). Programming for last 8 years (Visual C++ for the last 2 years).


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Question#pragma warning (disable : 4089) PinmemberRui Frazao6:42 18 May '12  
GeneralMy vote of 5 PinmemberThaddeus Jones9:07 3 Nov '11  
Questionhow to get the icon name in the system list? Pinmemberxylh200323:50 2 Aug '10  
QuestionHow to Find a larger icon than "large icon" on this program? Pinmembermahdigh5:26 24 Jan '09  
Question.exe Icon Pinmembernns20091:57 29 Dec '08  
How can I get application Icon(that we can see in Windows Explower) in C#?
GeneralThis is good! Pinmembervbnmjkkhgffd19:59 2 Apr '07  
AnswerFILE_ATTRIBUTE_NORMAL PinmembermikeT100023:36 18 Jun '07  
GeneralRe: FILE_ATTRIBUTE_NORMAL Pinmembervbnmjkkhgffd15:25 19 Jun '07  
GeneralRe: FILE_ATTRIBUTE_NORMAL PinmemberTristan Burtenshaw18:13 15 Feb '10  
Generali love it Pinmemberi_a_z2:32 28 Nov '06  
GeneralLarge Icon problem on Win XP PinmemberDave_isit121222:16 4 Apr '04  
GeneralSuggested improvements Pinmember.:fl0yd:.0:57 12 Feb '04  
QuestionHow to save as ico file PinsussAnonymous3:42 24 Jun '03  
AnswerRe: How to save as ico file Pinsussnpg42718:46 20 Apr '04  
GeneralNetwork Adapter Icon Pinsusssri7618:21 21 May '03  
GeneralI think the article is great PinmemberSteveKing7:22 7 Feb '03  
GeneralRe: I think the article is great PinmemberDiarrhio18:01 17 Mar '03  
GeneralRe: I think the article is great Pinmemberjaramilr14:57 12 Jun '04  
GeneralCome on guys!!! PinmemberMustafa Demirhan4:12 7 Feb '03  
GeneralRe: Come on guys!!! PinmemberMichael P Butler4:20 7 Feb '03  
GeneralRe: Come on guys!!! PinmemberJeff J9:28 9 Feb '03  
Generalremove this crap article from Cp. Thanks. Pinmember.S.Rod.2:11 7 Feb '03  
GeneralRe: remove this crap article from Cp. Thanks. PinmemberJörgen Sigvardsson2:27 7 Feb '03  
GeneralRe: remove this crap article from Cp. Thanks. Pinmember.S.Rod.2:44 7 Feb '03  
GeneralRe: remove this crap article from Cp. Thanks. PinmemberKarstenK3:10 7 Feb '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120529.1 | Last Updated 7 Feb 2003
Article Copyright 2003 by Doru Cioata
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid