Warm tip: This article is reproduced from serverfault.com, please click

Read 'Extended' file properties (C++)

发布于 2020-11-29 15:41:32

Is there a way to get all the properties and values of any file under the details tab using only c++ Code?
All extended file properties: link
I have seen solutions for c# but not c++. link
File properties of a png file

I have already looked into the fileapi.h function GetFileAttributesA() which gave me access to the file attribute constants like FILE_ATTRIBUTE_COMPRESSED, FILE_ATTRIBUTE_READONLY...

Even the GetFileAttributesExA() with GetFileExMaxInfoLevel was not able to return all the needed information.

if (FileAttributes & FILE_ATTRIBUTE_COMPRESSED) {
    std::cout << "File is compressed.";
}
if (FileAttributes & FILE_ATTRIBUTE_READONLY) {
    std::cout << "File is a readonly file.";
}

I thought there should be a similar thing for file properties something like GetFilePropertiesExA().
But could not find any similar function so far.
Also I was able to get information like Date created, modified and size using WIN32_FIND_DATA.

Questioner
Baron von Hoot
Viewed
0
tdoecke 2021-01-21 04:49:34

Here is some sample code from Microsoft for reading/writing file properties. It's using the WinAPI to read the file properties.

You can find a list of available properties here.

Depending on what you want to do, you may also take a look at these PROPVARIANT functions. For example, when you want to store the value of a property into a string.