Declare Function SetFileAttributes Lib "kernel32.dll" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long
SetFileAttributes changes the attributes of a file or a directory. The four attributes you can set are archive, read-only, hidden, and system status. Any of the four can be on or off in any order. The function returns 0 if an error occured, or a non-zero value if successful.
Example:
' Hide the file c:\apps\data.dat from the user
x = SetFileAttributes("C:\Apps\data.dat", FILE_ATTRIBUTES_ARCHIVE Or FILE_ATTRIBUTES_HIDDEN)
' Archive-type files are regular files
Related Call: GetFileAttributes
Category: Files
Back to the index.