Click here to Skip to main content
Click here to Skip to main content

An ShGetFileInfo Wrapper Class

, 6 Feb 2003
Rate this:
Please Sign up or sign in to vote.
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

Share

About the Author

Doru Cioata
Web Developer
Romania Romania
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).

Comments and Discussions

 
QuestionLicense PinmemberMember 108669435-Jun-14 8:04 
Question#pragma warning (disable : 4089) PinmemberRui Frazao18-May-12 7:42 
GeneralMy vote of 5 PinmemberThaddeus Jones3-Nov-11 10:07 
Questionhow to get the icon name in the system list? Pinmemberxylh20033-Aug-10 0:50 
QuestionHow to Find a larger icon than "large icon" on this program? Pinmembermahdigh24-Jan-09 6:26 
Question.exe Icon Pinmembernns200929-Dec-08 2:57 
GeneralThis is good! Pinmembervbnmjkkhgffd2-Apr-07 20:59 
AnswerFILE_ATTRIBUTE_NORMAL PinmembermikeT100019-Jun-07 0:36 
GeneralRe: FILE_ATTRIBUTE_NORMAL Pinmembervbnmjkkhgffd19-Jun-07 16:25 
GeneralRe: FILE_ATTRIBUTE_NORMAL PinmemberTristan Burtenshaw15-Feb-10 19:13 
Generali love it Pinmemberi_a_z28-Nov-06 3:32 
GeneralLarge Icon problem on Win XP PinmemberDave_isit12124-Apr-04 23:16 
GeneralSuggested improvements Pinmember.:fl0yd:.12-Feb-04 1:57 
QuestionHow to save as ico file PinsussAnonymous24-Jun-03 4:42 
AnswerRe: How to save as ico file Pinsussnpg42720-Apr-04 19:46 
GeneralNetwork Adapter Icon Pinsusssri7621-May-03 19:21 
GeneralI think the article is great PinmemberSteveKing7-Feb-03 8:22 
GeneralRe: I think the article is great PinmemberDiarrhio17-Mar-03 19:01 
GeneralRe: I think the article is great Pinmemberjaramilr12-Jun-04 15:57 
GeneralCome on guys!!! PinmemberMustafa Demirhan7-Feb-03 5:12 
GeneralRe: Come on guys!!! PinmemberMichael P Butler7-Feb-03 5:20 
GeneralRe: Come on guys!!! PinmemberJeff J9-Feb-03 10:28 
Generalremove this crap article from Cp. Thanks. Pinmember.S.Rod.7-Feb-03 3:11 
GeneralRe: remove this crap article from Cp. Thanks. PinmemberJörgen Sigvardsson7-Feb-03 3:27 
GeneralRe: remove this crap article from Cp. Thanks. Pinmember.S.Rod.7-Feb-03 3:44 

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.

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