|
|
Title | Use GetAttr to get a file's attributes |
Keywords | GetAttr, function, file, attributes |
Categories | Files and Directories |
|
|
The GetAttr function returns a bit mask giving file properties. Combine this value with the constants vbNormal, vbReadOnly, etc. using And to see which attributes the file has.
|
|
Private Sub Command1_Click()
Dim result As Long
result = GetAttr(txtFile.Text)
lblResult.Caption = "&&H" & Hex$(result)
If result And vbNormal Then
chkNormal.Value = vbChecked
Else
chkNormal.Value = vbUnchecked
End If
If result And vbReadOnly Then
chkReadOnly.Value = vbChecked
Else
chkReadOnly.Value = vbUnchecked
End If
If result And vbHidden Then
chkHidden.Value = vbChecked
Else
chkHidden.Value = vbUnchecked
End If
If result And vbSystem Then
chkSystem.Value = vbChecked
Else
chkSystem.Value = vbUnchecked
End If
If result And vbDirectory Then
chkDirectory.Value = vbChecked
Else
chkDirectory.Value = vbUnchecked
End If
If result And vbArchive Then
chkArchive.Value = vbChecked
Else
chkArchive.Value = vbUnchecked
End If
End Sub
|
|
Formatted by
Neil Crosby
|
|
|
|
|
|