Created
December 12, 2023 18:26
-
-
Save Sohamkadam333/312e2430baef1c8d80319f7bb7696889 to your computer and use it in GitHub Desktop.
Retrieves information about an object in the file system, such as a file, folder, directory, or drive root.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <windows.h> | |
using namespace std; | |
int main() | |
{ | |
CString filePath = L"E:\\samplefile.txt"; | |
SHFILEINFO shfi; | |
ZeroMemory(&shfi,sizeof(shfi)); | |
if(SHGetFileInfo(filePath,0,&shfi,sizeof(SHFILEINFO),SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME )) | |
{ | |
// Display the retrieved information | |
_tprintf(_T("Display Name: %s\n"), shfi.szDisplayName); | |
_tprintf(_T("File Type: %s\n"), shfi.szTypeName); | |
DestroyIcon(shfi.hIcon); | |
} | |
else | |
{ | |
cout<<"Error getting file info, Error no: "<<GetLastError()<<endl; | |
} | |
system("PAUSE"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment