
' ----------------------------------------------------------------------------
' FUNCTION    ChangeFileAttributes            DECEMBER 2001      by J.Philippe
'
'                  CHANGE  the  Attributes  of  a  FILE
'
' CODE FILE
' ----------------------------------------------------------------------------
'
' CHANGE FILE ATTRIBUTES
' ----------------------
'
Const FILE_ATTRIBUTE_ARCHIVE = &H20        ' "A"
Const FILE_ATTRIBUTE_DIRECTORY = &H10      ' "D"
Const FILE_ATTRIBUTE_HIDDEN = &H2          ' "H"
Const FILE_ATTRIBUTE_NORMAL = &H80         ' "N"
Const FILE_ATTRIBUTE_READONLY = &H1        ' "R"
Const FILE_ATTRIBUTE_SYSTEM = &H4          ' "S"
Const FILE_ATTRIBUTE_TEMPORARY = &H100     ' "T"
Const FILE_ATTRIBUTE_COMPRESSED = &H800    ' "C"
'    NO ATTRIBUTE SET                      ' "0"  ' zero
'
Declare Function SetFileAttributes Lib "kernel32" Alias "SetFileAttributesA" _
                    (ByRef lpFileName As String, ByVal dwFileAttributes As Long) As Long'
'
Function ChangeFileAttributes (sPathFileName As string, attributesAsString As String) As Long
    DefInt iAttributes
    DefStr pathFileName
    pathFileName = sPathFileName  
    iAttributes = 0
    attributesAsString = UCASE$(AttributesAsString)
    If Instr(attributesAsString, "A") Then iAttributes = iAttributes + FILE_ATTRIBUTE_ARCHIVE
    If Instr(attributesAsString, "D") Then iAttributes = iAttributes + FILE_ATTRIBUTE_DIRECTORY
    If Instr(attributesAsString, "H") Then iAttributes = iAttributes + FILE_ATTRIBUTE_HIDDEN
    If Instr(attributesAsString, "N") Then iAttributes = iAttributes + FILE_ATTRIBUTE_NORMAL
    If Instr(attributesAsString, "R") Then iAttributes = iAttributes + FILE_ATTRIBUTE_READONLY
    If Instr(attributesAsString, "S") Then iAttributes = iAttributes + FILE_ATTRIBUTE_SYSTEM
    If Instr(attributesAsString, "T") Then iAttributes = iAttributes + FILE_ATTRIBUTE_TEMPORARY
    If Instr(attributesAsString, "C") Then iAttributes = iAttributes + FILE_ATTRIBUTE_COMPRESSED
    Result = SetFileAttributes (pathFileName, iAttributes)
End Function
'
'
