Пример использованию API функции SearchTreeForFile

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
(*
The SearchTreeForFile function is used to search a tree for a specified file.
BOOL SearchTreeForFile(
IN LPSTR RootPath,
IN LPSTR InputPathName,
OUT LPSTR OutputPathBuffer
);
*)
uses ImageHlp;
{ for example }
var
str: PAnsiChar;
b: Boolean;
begin
WinExec('cmd /C mkdir c:\test\a\b\c\d\e\f\', SW_HIDE);
WinExec('cmd /C cmd /? > c:\test\a\b\c\d\e\f\cmd_help.txt', SW_HIDE);
ShowMessage('File created... maybe... :)');
str := GetMemory(MAX_PATH);
b := SearchTreeForFile('c:\test\', 'cmd_help.txt', str);
ShowMessage('Founded: ' + BoolToStr(b, True) + #13#10 + 'Path: ' + '"' + str + '"');
FreeMemory(str);
end;