windows_programming_notes.nbk: Home | Index | Next Page: GetFileAttributesEx | Previous Page: GetEnvironmentVariable


 GetFileAttributes

Retrieves a set of FAT file system attributes for a specified file or directory.

To get more attribute information, use the GetFileAttributesEx function.

To perform this operation as a transacted operation, use the [GetFileAttributesTransacted] function.

Syntax

    DWORD WINAPI GetFileAttributes(  
      __in  LPCTSTR lpFileName
    );

Parameters

In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.

Return Value

If the function succeeds, the return value contains the attributes of the specified file or directory.

If the function fails, the return value is INVALID_FILE_ATTRIBUTES. To get extended error information, call GetLastError.

The attributes can be one or more of the following values.

Remarks

When GetFileAttributes is called on a directory that contains a volume mount point, the file attributes returned are those of the directory where the volume mount point is set, not those of the root directory in a target mounted volume. To obtain the file attributes of a mounted volume, call GetVolumeNameForVolumeMountPoint to obtain the name of the target volume. Then use the resulting name in a call to GetFileAttributes. The results are the attributes of the root directory on the target volume.

If you call GetFileAttributes for a network share, the function fails, and GetLastError returns ERROR_BAD_NETPATH. You must specify a path to a subfolder on that share.

Symbolic link behavior—If the path points to a symbolic link, the function returns attributes for the symbolic link.

Transacted Operations

If a file is open for modification in a transaction, no other thread can open the file for modification until the transaction is committed. So if a transacted thread opens the file first, any subsequent threads that try modifying the file before the transaction is committed receives a sharing violation. If a non-transacted thread modifies the file before the transacted thread does, and the file is still open when the transaction attempts to open it, the transaction receives the error ERROR_TRANSACTIONAL_CONFLICT.

Requirements


windows_programming_notes.nbk: Home | Index | Next Page: GetFileAttributesEx | Previous Page: GetEnvironmentVariable


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time