GetFileAttributesEx
The GetFileAttributesEx function obtains attribute information about a specified file or directory.
Code:
BOOL GetFileAttributesEx(
LPCTSTR lpFileName, // file or directory name
GET_FILEEX_INFO_LEVELS fInfoLevelId, // attributes
LPVOID lpFileInformation // receives attributes
);
Parameters
lpFileName
Pointer to a null-terminated string that specifies a file or directory.
By default, this string is limited to MAX_PATH characters. The limit is related to how the GetFileAttributesEx function parses paths. An application can transcend this limit and send in paths longer than MAX_PATH characters by calling the wide (W) version of GetFileAttributesEx and prepending "\\?\" to the path. However, each component in the path cannot be more than MAX_PATH characters long. The "\\?\" tells the function to turn off path parsing. This technique also works with UNC names. The "\\?\" is ignored as part of the path. For example, "\\?\C:\myworld\private" is seen as "C:\myworld\private", and "\\?\UNC\peanuts\hotstuff\coolapps" is seen as "\\peanuts\hotstuff\coolapps".
fInfoLevelId
Specifies a GET_FILEEX_INFO_LEVELS enumeration type that gives the set of attribute information to obtain.
lpFileInformation
Pointer to a buffer that receives the attribute information. The type of attribute information stored into this buffer is determined by the value of fInfoLevelId.
Return Values
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get extended error information, call GetLastError.