06-05-2023, 11:58 PM
Can you tell me if this is correct..
If the entire problem is with the function declaration then I have got it wrong the whole time.
Code: (Select All)
Rem $Dynamic
DefLng A-Z
Declare Dynamic Library "kernel32"
Function CloseHandle& (ByVal hfile As _Offset)
End Declare
Rem hfind = CreateFileA(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%&)
End Declare
Dim hfind As _Offset
' 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: "; Hex$(hfind)
r = CloseHandle(hfind)
End If
End If
End