SEARCHTREEFORFILE - API FILE SEARCH

Home

API File Search
Filedialogs
The FILES statement
The FILES statement in action
Open Source Editor for WinXP
Spotlight on John Fisher
Using Winsock
Winsock API Reference

(LB3+ only!)

From the ebook, Mastering Liberty BASIC 3:
*****************************************
Find a file quickly with the SearchTreeForFile function from "imagehlp" DLL. RootPath$ is a pointer to a null- terminated string that specifies the path where the function should begin searching for the file. InputPathName$ is a pointer to a null-terminated string that specifies the file for which the function will search. A program can use a partial path. OutputPathBuffer$ is a pointer to a buffer that receives the full path to the file that is found. This string is not modified if the return value is FALSE. Below is a small demo. Choose to try searching for the filename alone, or filename with partial path.

     RootPath$="c:\"
     'InputPathName$="bmp\copy.bmp" + chr$(0) 'includes partial path
     InputPathName$="liberty.exe" + chr$(0) 'filename only
     OutputPathBuffer$=space$(1023)+chr$(0)
open "imagehlp" for dll as #ih
     calldll #ih, "SearchTreeForFile",_
     RootPath$ as ptr,_
     InputPathName$ as ptr,_
     OutputPathBuffer$ as ptr,_
     ret as long
     close #ih
print "Searching (c:\) for ";InputPathName$
     if ret=0 then
     print InputPathName$;" not found."
     else
     print "Full path is ";trim$(OutputPathBuffer$)
end if
     print "Finished"
     end

See below for an example of this function as it is used in the Open Source Editor.


Home

API File Search
Filedialogs
The FILES statement
The FILES statement in action
Open Source Editor for WinXP
Spotlight on John Fisher
Using Winsock
Winsock API Reference