SetFileAttributes Function
Sets the specified attributes for a file or a directory.
Syntax
BOOL SetFileAttributes(
[in] LPCTSTR lpFileName,
[in] DWORD dwFileAttributes
);
Parameters
| Parameter | Description |
|---|---|
lpFileName |
A pointer to a null-terminated string that specifies the name of the file or directory for which the attributes are to be set. |
dwFileAttributes |
The file attributes to set for the specified file or directory. This parameter can be a combination of the following values:
|
Return value
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
The following attributes are not supported by the SetFileAttributes function:
FILE_ATTRIBUTE_DIRECTORYFILE_ATTRIBUTE_ENCRYPTEDFILE_ATTRIBUTE_OFFLINE
If you attempt to set one of these attributes, the function fails and GetLastError returns ERROR_INVALID_PARAMETER.
Note: The system can map a higher file attribute, such as
FILE_ATTRIBUTE_ARCHIVE, to the FILE_ATTRIBUTE_NORMAL attribute.
Important: Applications should not create files with the
FILE_ATTRIBUTE_DIRECTORY attribute.
Requirements
Header: windows.h
Library: Kernel32.lib
DLL: Kernel32.dll