Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
500MB 27GB Web Hosting - $9.95/Month
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
TitleUse GetAttr to get a file's attributes
KeywordsGetAttr, function, file, attributes
CategoriesFiles & 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
 
 
Copyright © 1997-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated