SHGetFileInfo는 매우 유용한 API다
어찌나 친절한 지 File의 정보를 몽땅 건내준다
(심지어 아이콘 정보까지 말이다)
여기서는 간단하게 파일 속성을 알기 위한 용도로 사용했다
SHFILEINFO shInfo;
....
SHGetFileInfo(strDrive,0,&shInfo,sizeof(SHFILEINFO),SHGFI_TYPENAME | SHGFI_ATTRIBUTES);
....
if ( !(shInfo.dwAttributes & SFGAO_HIDDEN) )
// 숨김파일은 제외한다 코딩
여기서 붉은색 플래그는
#define SHGFI_ICON 0x000000100 // get icon
#define SHGFI_DISPLAYNAME 0x000000200 // get display name
#define SHGFI_TYPENAME 0x000000400 // get type name
#define SHGFI_ATTRIBUTES 0x000000800 // get attributes
#define SHGFI_ICONLOCATION 0x000001000 // get icon location
#define SHGFI_EXETYPE 0x000002000 // return exe type
#define SHGFI_SYSICONINDEX 0x000004000 // get system icon index
#define SHGFI_LINKOVERLAY 0x000008000 // put a link overlay on icon
#define SHGFI_SELECTED 0x000010000 // show icon in selected state
#define SHGFI_ATTR_SPECIFIED 0x000020000 // get only specified attributes
#define SHGFI_LARGEICON 0x000000000 // get large icon
#define SHGFI_SMALLICON 0x000000001 // get small icon
#define SHGFI_OPENICON 0x000000002 // get open icon
#define SHGFI_SHELLICONSIZE 0x000000004 // get shell size icon
#define SHGFI_PIDL 0x000000008 // pszPath is a pidl
#define SHGFI_USEFILEATTRIBUTES 0x000000010 // use passed dwFileAttribute
로 정의 되어 있다
이 플래그를 or로 추가해주면 필요한 정보를 얻어올 수 있다
여기서 오랜지색 플래그는
#define SFGAO_CANCOPY DROPEFFECT_COPY // Objects can be copied (0x1)
#define SFGAO_CANMOVE DROPEFFECT_MOVE // Objects can be moved (0x2)
#define SFGAO_CANLINK DROPEFFECT_LINK // Objects can be linked (0x4)
#define SFGAO_STORAGE 0x00000008L // supports BindToObject(IID_IStorage)
#define SFGAO_CANRENAME 0x00000010L // Objects can be renamed
#define SFGAO_CANDELETE 0x00000020L // Objects can be deleted
#define SFGAO_HASPROPSHEET 0x00000040L // Objects have property sheets
#define SFGAO_DROPTARGET 0x00000100L // Objects are drop target
#define SFGAO_CAPABILITYMASK 0x00000177L
#define SFGAO_ENCRYPTED 0x00002000L // object is encrypted (use alt color)
#define SFGAO_ISSLOW 0x00004000L // 'slow' object
#define SFGAO_GHOSTED 0x00008000L // ghosted icon
#define SFGAO_LINK 0x00010000L // Shortcut (link)
#define SFGAO_SHARE 0x00020000L // shared
#define SFGAO_READONLY 0x00040000L // read-only
#define SFGAO_HIDDEN 0x00080000L // hidden object
#define SFGAO_DISPLAYATTRMASK 0x000FC000L
#define SFGAO_FILESYSANCESTOR 0x10000000L // may contain children with SFGAO_FILESYSTEM
#define SFGAO_FOLDER 0x20000000L // support BindToObject(IID_IShellFolder)
#define SFGAO_FILESYSTEM 0x40000000L // is a win32 file system object (file/folder/root)
#define SFGAO_HASSUBFOLDER 0x80000000L // may contain children with SFGAO_FOLDER
#define SFGAO_CONTENTSMASK 0x80000000L
#define SFGAO_VALIDATE 0x01000000L // invalidate cached information
#define SFGAO_REMOVABLE 0x02000000L // is this removeable media?
#define SFGAO_COMPRESSED 0x04000000L // Object is compressed (use alt color)
#define SFGAO_BROWSABLE 0x08000000L // supports IShellFolder, but only implements CreateViewObject() (non-folder view)
#define SFGAO_NONENUMERATED 0x00100000L // is a non-enumerated object
#define SFGAO_NEWCONTENT 0x00200000L // should show bold in explorer tree
#define SFGAO_CANMONIKER 0x00400000L // defunct
#define SFGAO_HASSTORAGE 0x00400000L // defunct
#define SFGAO_STREAM 0x00400000L // supports BindToObject(IID_IStream)
#define SFGAO_STORAGEANCESTOR 0x00800000L // may contain children with SFGAO_STORAGE or SFGAO_STREAM
#define SFGAO_STORAGECAPMASK 0x70C50008L // for determining storage capabilities, ie for open/save semantics
....
겁나 길다, 하지만 대충 봐도 알아 챌거니 자세한 설명은 생략한다
보기에는 많아 보이지만 예를들어
파일 속성에는 (읽기전용, 숨김, 링크, 삭제 가능/불가 등등)이 들어간다
[출처] http://counts.tistory.com/18
'old drawer > C, C++, MFC' 카테고리의 다른 글
WinExec() CreateProcess() ShellEcecute() ShellExecuteEx() (0) | 2013.02.01 |
---|---|
[Win32 API] ExpandEnvironmentStrings (0) | 2013.01.11 |
[MFC/C++] 레지스트리 값 쓰기/읽기 (1) | 2013.01.11 |
[C/C++] 레지스트리 사용법 (0) | 2013.01.11 |
[MFC] 파일 복사 함수 (0) | 2013.01.07 |