Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetFileAttributes - Interpretation of returned value

Status
Not open for further replies.

Kevats

Programmer
Apr 19, 2002
8
IT
Hi

I'm trying to use GetFileAttributes function of the Kernel32 Dll. Does anyone know how to interpret the unsigned long that is returned inorder to glean the read, write, archive and system attribute settings?

Thanks

Kevats
 
Hi,
Info is available on the following address


In case, you are not able to access the page, these are the contents.

GetFileAttributes Function
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:

FILE_ATTRIBUTE_ARCHIVE = &H20
An archive file (which most files are).
FILE_ATTRIBUTE_COMPRESSED = &H800
A file residing in a compressed drive or directory.
FILE_ATTRIBUTE_DIRECTORY = &H10
A directory instead of a file.
FILE_ATTRIBUTE_HIDDEN = &H2
A hidden file, not normally visible to the user.
FILE_ATTRIBUTE_NORMAL = &H80
An attribute-less file (cannot be combined with other attributes).
FILE_ATTRIBUTE_READONLY = &H1
A read-only file.
FILE_ATTRIBUTE_SYSTEM = &H4
A system file, used exclusively by the operating system.
lpFileName
The full name of the file or directory to check the attributes of, including the full path.
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 &quot;Archive&quot;
If (attribs And FILE_ATTRIBUTES_HIDDEN) <> 0 Then Debug.Print &quot;Hidden&quot;
If (attribs And FILE_ATTRIBUTES_READONLY) <> 0 Then Debug.Print &quot;Read-only&quot;
' etc....


Rajeshwar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top