Checking that folder / file is hidden / system in Windows C / C ++
I am writing a Cross platform application using C ++ / STL / Boost and I realized that they do not provide a way to check if a folder or file is hidden or is a system file on Windows.
What's the easiest way to do this in C / C ++ for Windows?
Ideally I have a std :: string with an outline (either with a file or folder), or with a return if hidden or is a system file. best if it works on all Windows versions. I am also using MinGW g ++ to compile this.
+2
source to share
1 answer
GetFileAttributes will work for this.
It takes a file or directory path as a parameter and returns a set of flags including FILE_ATTRIBUTE_HIDDEN and FILE_ATTRIBUTE_SYSTEM.
DWORD attributes = GetFileAttributes(path);
if (attributes & FILE_ATTRIBUTE_HIDDEN) ...
if (attributes & FILE_ATTRIBUTE_SYSTEM) ...
+3
source to share