*-------------------------------------------------------------------------- #define TRUE .t. #define FALSE .f. #define T_HANDLE Integer #define LPCTSTR String @ #define DWORD integer #define LPSECURITY_ATTRIBUTES string @ declare T_HANDLE CreateFile in Kernel32.dll ; LPCTSTR FileName, ; DWORD dwDesiredAccess, ; DWORD dwShareMode, ; LPSECURITY_ATTRIBUTES lpSecurityAttributes, ; DWORD dwCreationDisposition, ; DWORD dwFlagsAndAttributes, ; T_HANDLE hTemplateFile declare integer CloseHandle in win32api long Handle declare Integer GetFileAttributes in win32api string @ #define FILE_ATTRIBUTE_READONLY 0x00000001 #define FILE_ATTRIBUTE_HIDDEN 0x00000002 #define FILE_ATTRIBUTE_SYSTEM 0x00000004 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020 #define FILE_ATTRIBUTE_ENCRYPTED 0x00000040 #define FILE_ATTRIBUTE_NORMAL 0x00000080 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800 #define FILE_ATTRIBUTE_OFFLINE 0x00001000 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 #define GENERIC_READ (0x80000000) #define GENERIC_WRITE (0x40000000) #define GENERIC_EXECUTE (0x20000000) #define GENERIC_ALL (0x10000000) #define CREATE_NEW 1 #define CREATE_ALWAYS 2 #define OPEN_EXISTING 3 #define OPEN_ALWAYS 4 #define TRUNCATE_EXISTING 5 #define INVALID_HANDLE_VALUE (-1) #define INVALID_FILE_SIZE (-1) #define INVALID_SET_FILE_POINTER (-1) #define INVALID_FILE_ATTRIBUTES (-1) function FileOpened( FileName ) local Handle Handle = CreateFile( ; @FileName, ; GENERIC_READ, ; 0, ; && excl access 0, ; OPEN_EXISTING, ; FILE_ATTRIBUTE_NORMAL, ; 0 ; ) do case case (m.Handle = INVALID_HANDLE_VALUE ) return FileExists(m.FileName) otherwise =CloseHandle(m.Handle) return FALSE endcase assert FALSE endfunc *-------------------------------------------------------------------------- *-------------------------------------------------------------------------- Function FileExists(FileName) return (GetFileAttributes(@FileName) <> INVALID_FILE_ATTRIBUTES) endfunc *--------------------------------------------------------------------------