Click here to Skip to main content
6,822,123 members and growing! (17,975 online)
Email Password   helpLost your password?
Desktop Development » Files and Folders » General     Intermediate

An ShGetFileInfo Wrapper Class

By Doru Cioata

A class built around the use of ShGetFileInfo() function.
VC6, VC7Win2K, WinXP, MFC, Dev
Posted:6 Feb 2003
Views:83,752
Bookmarked:27 times
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
30 votes for this article.
Popularity: 5.61 Rating: 3.80 out of 5
5 votes, 16.7%
1

2
4 votes, 13.3%
3
4 votes, 13.3%
4
17 votes, 56.7%
5

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


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

Occupation: Web Developer
Location: Romania Romania

Other popular Files and Folders articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 29 (Total in Forum: 29) (Refresh)FirstPrevNext
GeneralHow to Find a larger icon than "large icon" on this program? Pinmembermahdigh6:26 24 Jan '09  
Question.exe Icon Pinmembernns20092:57 29 Dec '08  
GeneralThis is good! Pinmembervbnmjkkhgffd20:59 2 Apr '07  
AnswerFILE_ATTRIBUTE_NORMAL PinmembermikeT10000:36 19 Jun '07  
GeneralRe: FILE_ATTRIBUTE_NORMAL Pinmembervbnmjkkhgffd16:25 19 Jun '07  
Generali love it Pinmemberi_a_z3:32 28 Nov '06  
GeneralLarge Icon problem on Win XP PinmemberDave_isit121223:16 4 Apr '04  
GeneralSuggested improvements Pinmember.:fl0yd:.1:57 12 Feb '04  
GeneralHow to save as ico file PinsussAnonymous4:42 24 Jun '03  
GeneralRe: How to save as ico file Pinsussnpg42719:46 20 Apr '04  
GeneralNetwork Adapter Icon Pinsusssri7619:21 21 May '03  
GeneralI think the article is great PinmemberSteveKing8:22 7 Feb '03  
GeneralRe: I think the article is great PinmemberDiarrhio19:01 17 Mar '03  
GeneralRe: I think the article is great Pinmemberjaramilr15:57 12 Jun '04  
GeneralCome on guys!!! PinmemberMustafa Demirhan5:12 7 Feb '03  
GeneralRe: Come on guys!!! PinmemberMichael P Butler5:20 7 Feb '03  
GeneralRe: Come on guys!!! PinmemberJeff J10:28 9 Feb '03  
Generalremove this crap article from Cp. Thanks. Pinmember.S.Rod.3:11 7 Feb '03  
GeneralRe: remove this crap article from Cp. Thanks. PinmemberJörgen Sigvardsson3:27 7 Feb '03  
GeneralRe: remove this crap article from Cp. Thanks. Pinmember.S.Rod.3:44 7 Feb '03  
GeneralRe: remove this crap article from Cp. Thanks. PinmemberKarstenK4:10 7 Feb '03  
GeneralRe: remove this crap article from Cp. Thanks. Pinmember.:fl0yd:.2:45 11 Feb '04  
GeneralRe: remove this crap article from Cp. Thanks. PinmemberKarstenK3:59 11 Feb '04  
GeneralRe: remove this crap article from Cp. Thanks. Pinmember.:fl0yd:.4:15 11 Feb '04  
GeneralRe: remove this crap article from Cp. Thanks. PinmemberJörgen Sigvardsson4:46 7 Feb '03  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

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

PermaLink | Privacy | Terms of Use
Last Updated: 6 Feb 2003
Editor: Heath Stewart
Copyright 2003 by Doru Cioata
Everything else Copyright © CodeProject, 1999-2010
Web21 | Advertise on the Code Project