How to get help information through native windows API?

I can get the created date, file size, etc. for the file using the following code:

// Error handling removed for brevity 
HANDLE hFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, 
             NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 

LARGE_INTEGER fileSize; 
GetFileSizeEx(hFile, &fileSize); 

FILE_BASIC_INFO fileInfo); 
GetFileInformationByHandle(hFile, FileBasicInfo, fileInfo, sizeof(fileInfo)); 

But when called against a directory, all values ​​are zero - how do I get directory information?

thank

+3
source share
1 answer

I came across something similar when you need to pass this flag to get a valid descriptor for a directory. From an MSDN document .

try it

HANDLE hFile = CreateFile(path, GENERIC_READ, FILE_SHARE_READ, 
         NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_BACKUP_SEMANTICS, NULL); 

FILE_FLAG_BACKUP_SEMANTICS | . . . "".

+8

Source: https://habr.com/ru/post/1735231/


All Articles