Windows Dev Center

Expand Minimize

SearchTreeForFile function

Searches a directory tree for a specified file.

Syntax


BOOL WINAPI SearchTreeForFile(
  _In_  PCTSTR RootPath,
  _In_  PCTSTR InputPathName,
  _Out_ PTSTR  OutputPathBuffer
);

Parameters

RootPath [in]

The path where the function should begin searching for the file.

InputPathName [in]

The file for which the function will search. You can use a partial path.

OutputPathBuffer [out]

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.

Return value

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE. To retrieve extended error information, call GetLastError.

Remarks

The function searches for the file specified by the InputPathName parameter beginning at the path specified in the RootPath parameter. The maximum path depth that is allowed in the RootPath is 32 directories. When the function finds the file in the directory tree, it places the full path to the file in the buffer specified by the OutputPathBuffer parameter. The underlying file system specifies the order of the subdirectory search.

The search can be canceled if you register a SymRegisterCallbackProc64 callback function. For every directory searched, SearchTreeForFile calls this callback function with CBA_DEFERRED_SYMBOL_LOAD_CANCEL. If the callback function returns TRUE, SearchTreeForFile cancels the search.

This function triggers one CBA_DEFERRED_SYMBOL_LOAD_CANCEL event per directory searched. This allows the caller to cancel the search.

All DbgHelp functions, such as this one, are single threaded. Therefore, calls from more than one thread to this function will likely result in unexpected behavior or memory corruption. To avoid this, you must synchronize all concurrent calls from more than one thread to this function.

To call the Unicode version of this function, define DBGHELP_TRANSLATE_TCHAR.

Requirements

Redistributable

DbgHelp.dll 5.1 or later

Header

Dbghelp.h

Library

Dbghelp.lib

DLL

Dbghelp.dll

Unicode and ANSI names

SearchTreeForFileW (Unicode) and SearchTreeForFile (ANSI)

See also

DbgHelp Functions

 

 

Community Additions

ADD
Show:
© 2015 Microsoft