Declare Function GetFileAttributes Lib "kernel32.dll" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
Platforms: Win 32s, Win 95/98, Win NT
GetFileAttributes returns the attributes of a file or a directory. Attributes determine such things as read-only status, archive status (most files are), hidden status, etc. If the function fails, it will return 0. If the file or directory cannot be found, it will return -1. Otherwise, the return value will be one or more of the following file attribute flags:
Example:
' Display the attributes of C:\Files\program.exe
Dim attribs As Long ' receives file attributes
attribs = GetFileAttributes("C:\Files\program.exe") ' read file attributes
If (attribs And FILE_ATTRIBUTES_ARCHIVE) <> 0 Then Debug.Print "Archive"
If (attribs And FILE_ATTRIBUTES_HIDDEN) <> 0 Then Debug.Print "Hidden"
If (attribs And FILE_ATTRIBUTES_READONLY) <> 0 Then Debug.Print "Read-only"
' etc....
See Also: GetFileInformationByHandle, SetFileAttributes
Category: Files
Go back to the alphabetical Function listing.
Go back to the Reference section index.
This page is copyright © 2000 Paul Kuliniewicz. Copyright Information.
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/g/getfileattributes.html