Setting File Attributes:   Return to List

' Declarations
Const READONLY = &H1
Const HIDDEN = &H2
Const SYSTEM = &H4
Const ARCHIVE = &H20
Const NORMAL = &H80

Private Declare Function SetFileAttributes Lib "kernel32.dll" Alias _
    "SetFileAttributesA" (ByVal lpFileName As String, _
    ByVal dwFileAttributes As Long) As Long

' Code:
Public Sub Set_Attributes()
Dim attr As Long
Dim rval As Long
attr = READONLY + SYSTEM + HIDDEN
rval = SetFileAttributes("C:\Temp\Test.txt", attr)
End Sub



Note to Webmaster