CreateFile library error
#13
What if I am using the following to get a filename/directory attribute:

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
Reply


Messages In This Thread
CreateFile library error - by eoredson - 06-05-2023, 05:42 AM
RE: CreateFile library error - by DSMan195276 - 06-05-2023, 05:56 AM
RE: CreateFile library error - by eoredson - 06-05-2023, 10:35 PM
RE: CreateFile library error - by DSMan195276 - 06-05-2023, 10:59 PM
RE: CreateFile library error - by eoredson - 06-05-2023, 11:58 PM
RE: CreateFile library error - by DSMan195276 - 06-06-2023, 12:11 AM
RE: CreateFile library error - by mnrvovrfc - 06-06-2023, 12:05 AM
RE: CreateFile library error - by eoredson - 06-06-2023, 01:34 AM
RE: CreateFile library error - by DSMan195276 - 06-06-2023, 03:15 AM
RE: CreateFile library error - by eoredson - 06-06-2023, 02:14 AM
RE: CreateFile library error - by eoredson - 06-06-2023, 03:43 AM
RE: CreateFile library error - by DSMan195276 - 06-06-2023, 04:02 AM
RE: CreateFile library error - by eoredson - 06-06-2023, 04:08 AM
RE: CreateFile library error - by eoredson - 06-06-2023, 04:29 AM
RE: CreateFile library error - by Ultraman - 06-06-2023, 06:06 AM
RE: CreateFile library error - by DSMan195276 - 06-06-2023, 06:23 AM
RE: CreateFile library error - by Ultraman - 06-07-2023, 09:44 PM
RE: CreateFile library error - by DSMan195276 - 06-07-2023, 10:09 PM
RE: CreateFile library error - by eoredson - 06-08-2023, 01:14 AM
RE: CreateFile library error - by eoredson - 06-08-2023, 03:00 AM
RE: CreateFile library error - by SMcNeill - 06-08-2023, 03:29 AM



Users browsing this thread: 11 Guest(s)