Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
MSDN Library
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.


Windows Mobile 6.5
A version of this page is also available for

This function obtains attributes for a specified file or directory. A RAPI version of this function exists called CeGetFileAttributes (RAPI).

DWORD GetFileAttributes(
  LPCTSTR lpFileName 


[in] Pointer to a null-terminated string that specifies the name of a file or directory.

The default string size limit for paths is MAX_PATH characters. This limit is related to how this function parses paths.

The attributes of the specified file or directory, returned in a DWORD, indicate success. 0xFFFFFFFF indicates failure. To get extended error information, call GetLastError.

The following table shows possible values.

Value Description


The file or directory is an archive file or directory. Applications use this attribute to mark files for backup or removal.


The file or directory is compressed. For a file, this means that all data in the file is compressed. For a directory, this means that compression is the default for newly created files and subdirectories.


The object is a directory.


The file or directory is encrypted. For a file, this means that all data streams are encrypted. For a directory, this means that encryption is the default for newly created files and subdirectories.


The file or directory is hidden. Hidden files and directories are not included in a typical directory listing.


This file is an OS file stored in ROM. These files are read-only and cannot be modified.


The file has no other attributes set. This attribute is valid only if used alone.


The file or directory is read-only. Applications can read the file, but cannot write to it or delete it. If it is a directory, applications cannot delete or move it.


This file is an OS file stored in ROM and run directly from ROM, rather than being first copied to RAM. The CreateFile function cannot be used to access this file. Instead, use the LoadLibrary and the CreateProcess functions.


The file is a DLL module that has an implicit reference from at least one other file that is in the modules section of the image. A file with this attribute cannot replace the functionality of the DLL with a RAM copy of the same DLL. A file with this attribute must also have the FILE_ATTRIBUTE_INROM and the FILE_ATTRIBUTE_ROMMODULE attributes.


The file or directory is part of, or is used exclusively by, the OS.


The file is being used for temporary storage. File systems attempt to keep the data in memory for quicker access, rather than flushing the data back to mass storage. A temporary file should be deleted by the application as soon as it is no longer needed.

Windows Embedded CEWindows CE 1.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions

© 2015 Microsoft