Author | Page created on | Page updated on |
George de Greef | 27.06.02 |
DLL calls used by this example |
Download available as: |
MapBasic . Copy/Paste to a new MB page if needed, or download if available. |
include "mapbasic.def"
Define MAX_PATH 260 Define INVALID_HANDLE_VALUE -1
' Almost all the defines for the "dwFileAttributes" argument of WIN32_FIND_DATA ' Only "_DIRECTORY" is required for this example Define FILE_ATTRIBUTE_ARCHIVE &H20 Define FILE_ATTRIBUTE_DIRECTORY &H10 Define FILE_ATTRIBUTE_HIDDEN &H2 Define FILE_ATTRIBUTE_NORMAL &H80 Define FILE_ATTRIBUTE_READONLY &H1 Define FILE_ATTRIBUTE_SYSTEM &H4 Define FILE_ATTRIBUTE_TEMPORARY &H100
Type FILETIME dwLowDateTime As Integer dwHighDateTime As Integer End Type
Type WIN32_FIND_DATA dwFileAttributes As Integer ftCreationTime As FILETIME ftLastAccessTime As FILETIME ftLastWriteTime As FILETIME nFileSizeHigh As Integer nFileSizeLow As Integer dwReserved0 As Integer dwReserved1 As Integer cFileName As String * MAX_PATH cAlternate As String * 14 End Type
Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String,lpFindFileData As WIN32_FIND_DATA) As Integer Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Integer,lpFindFileData As WIN32_FIND_DATA) As Integer Declare Function FindClose Lib "kernel32" Alias "FindClose" (ByVal hFindFile As Integer) As Integer ' The files will be listed in the message box and stored in the CName() array
Dim hndl, I, J, p as Integer Dim CNames(), name as string Dim fileinfo As WIN32_FIND_DATA
' To get all the tables in the "c:\data\europe\" directory, ' define the string variable "name" as follows
name="c:\data\europe\*.TAB" StatusBar Message "Searching " + name hndl = FindFirstFile(name, fileinfo) If hndl <> INVALID_HANDLE_VALUE Then Do If (fileinfo.dwFileAttributes MOD (FILE_ATTRIBUTE_DIRECTORY * 2)) \ FILE_ATTRIBUTE_DIRECTORY <> 1 Then I = ubound(CNames) + 1 Redim CNames(I) CNames(I) = pathtodirectory$(name) + fileinfo.cFileName print cnames(i) end if Loop While FindNextFile(hndl, fileinfo) = TRUE end If
' The call to FindClose() is required to end the search I = FindClose(hndl)
|
Comments: |