VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Get File Attributes using GetFileAttributes API

by Karthikeyan (187 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 1st August 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Get File Attributes using GetFileAttributes API

API Declarations


Const HIDDEN = &H2
Const SYSTEM = &H4
Const DIRECTORY = &H10
Const ARCHIVE = &H20
Const NORMAL = &H80
Const COMPRESSED = &H800
Private Declare Function GetFileAttributes Lib "kernel32.dll" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long


Rate Get File Attributes using GetFileAttributes API



Dim val As String
Dim attr As Long
attr = GetFileAttributes("C:\karthik\waste.txt")
If (attr And &H1) = &H1 Then
val = " Read Only,"
End If
If (attr And &H2) = &H2 Then
val = val & " Hidden,"
End If
If (attr And &H4) = &H4 Then
val = val & " System,"
End If
If (attr And &H20) = &H20 Then
val = val & " Archive,"
End If
If (attr And &H80) = &H80 Then
val = val & " Normal,"
End If
If (attr And &H800) = &H800 Then
val = val & " Compressed,"
End If
val = Left(val, Len(val) - 1)
If (attr And &H10) = &H10 Then
MsgBox "Given directory has " & val & " attributes"
Else
MsgBox "Given file has " & val & " attributes"
End If
End
End Sub


Download this snippet    Add to My Saved Code

Get File Attributes using GetFileAttributes API Comments

No comments have been posted about Get File Attributes using GetFileAttributes API. Why not be the first to post a comment about Get File Attributes using GetFileAttributes API.

Post your comment

Subject:
Message:
0/1000 characters