06-06-2023, 04:08 AM
What if I am using the following to get a filename/directory attribute:
Does this throw a 64-bit compilation error as well?
Does this throw a 64-bit compilation error as well?
Code: (Select All)
Rem $Dynamic
DefLng A-Z
Declare Dynamic Library "kernel32"
Function CloseHandle& (ByVal hfile As _Offset)
End Declare
Rem hfind = CreateFile(ASCIIZ, &H180, &H3, 0, 3, 0, 0)
' parameters:
' (1) pointer to filename
' (2) access:
' x80(128) - read
' x100(256) - write
' (3) sharing
' (4) security attributes
' (5) create file flag
' (6) flags (standard OSHA)
' (7) pointer to template file
' paramater 5
' 0 DEFAULT_OPEN_EXISTING = open only if exists
' 1 CREATE_NEW = create only if not exist
' 2 CREATE_ALWAYS = always create new file
' 3 OPEN_EXISTING = open only if exists
' 4 OPEN_ALWAYS = open file always
' 5 TRUNCATE_EXISTING = open/truncate to 0 only if exists
' 6 OPEN_DIRECTORY = open if directory exists
Declare Library
Function CreateFileA%& (filename$, Byval access&, Byval sharing&, Byval sec_attr%&, Byval create&, Byval flags&, Byval template%&)
Function GetFileAttributes& (f$)
End Declare
Dim hfind As _Offset
Dim Attribute As _Unsigned Long
' detect file
Print "Enter filename";
Input f$
If Len(f$) Then
f$ = f$ + Chr$(0)
hfind = CreateFileA(f$, &H180, 0, 0, 3, 0, 0)
If hfind Then
Print "File exists."
Print "Handle: "; hfind
r = CloseHandle(hfind)
Attribute = GetFileAttributes&(f$)
If (Attribute And &H1) = &H1 Then Print " Read-only"
If (Attribute And &H2) = &H2 Then Print " Hidden"
If (Attribute And &H4) = &H4 Then Print " System"
If (Attribute And &H10) = &H10 Then Print " Directory"
If (Attribute And &H20) = &H20 Then Print " Archive"
End If
End If
End