Declare Function SetFileAttributes Lib "kernel32.dll" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long
Platforms: Win 32s, Win 95/98, Win NT
SetFileAttributes changes the attributes of a file or a directory. The four attributes you can set are archive, read-only, hidden, and system status -- the other attributes merely reflect unchangeable properties of the file. Any of the four can be on or off in any order. The function returns 0 if an error occured, or 1 if successful.
Example:
' Set the file C:\MyProgram\secret.dat to a hidden, read-only,
' archive file.
Dim fileattrs As Long ' file attributes
Dim retval As Long ' return value
fileattrs = FILE_ATTRIBUTES_ARCHIVE Or FILE_ATTRIBUTES_HIDDEN Or FILE_ATTRIBUTES_READONLY
retval = SetFileAttributes("C:\MyProgram\secret.dat", fileattrs) ' set the file's attributes
Related Call: GetFileAttributes
Category: Files
Back to the index.