In the following posts you will find 2 versions of ScanDir.inc.
The following examples are based on ScanDir.inc version 2.
In the last post you find ScanDir.inc version 3. The parameters
in the user-defined callback-function is changed in this version.
The ScanDir function scans directories. The criteria of the scan is defined by a user-defined callback function.
The following 2 examples use the include-file "scandir.inc". This file is given in the next post.
Regards
Peter
Example 1
Example 2
[This message has been edited by Peter P Stephensen (edited August 29, 2001).]
The following examples are based on ScanDir.inc version 2.
In the last post you find ScanDir.inc version 3. The parameters
in the user-defined callback-function is changed in this version.
The ScanDir function scans directories. The criteria of the scan is defined by a user-defined callback function.
The following 2 examples use the include-file "scandir.inc". This file is given in the next post.
Regards
Peter
Example 1
Code:
#COMPILE EXE #INCLUDE "win32api.inc" #INCLUDE "ScanDir.inc" GLOBAL PathHit AS STRING ' User-defined callback function defining the criteria of the scan FUNCTION ScanFunc(BYVAL File AS STRING, BYVAL Path AS STRING) AS LONG IF LCASE$(File) = "win32api.inc" THEN PathHit = Path FUNCTION = %SCAN_END ' If find file: end scan END IF END FUNCTION FUNCTION PBMAIN ScanDir "c:", CODEPTR(ScanFunc), %TRUE MSGBOX PathHit END FUNCTION
Code:
#COMPILE EXE #INCLUDE "win32api.inc" #INCLUDE "ScanDir.inc" GLOBAL FileHit() AS STRING GLOBAL i AS LONG ' User-defined callback function defining the criteria of the scan FUNCTION ScanFunc(BYVAL File AS STRING, BYVAL Path AS STRING) AS LONG IF INSTR(LCASE$(File),".exe") THEN FileHit(i) = Path & "\" & File INCR i END IF END FUNCTION FUNCTION PBMAIN LOCAL n AS LONG LOCAL hDlg AS LONG REDIM FileHit(10000) ScanDir "c:", CODEPTR(ScanFunc), %TRUE REDIM PRESERVE FileHit(i) DIALOG NEW 0, "Number of files: " & FORMAT$(i+1),,,200, 200, %WS_SYSMENU OR %DS_CENTER TO hDlg CONTROL ADD LISTBOX, hDlg, 100, FileHit(), 0,0,197,200, %WS_VSCROLL, %WS_EX_CLIENTEDGE DIALOG SHOW MODAL hDlg END FUNCTION
[This message has been edited by Peter P Stephensen (edited August 29, 2001).]
Comment