SearchTreeForFile Function

Debug Help Library

SearchTreeForFile Function

Searches a directory tree for a specified file.

BOOL WINAPI SearchTreeForFile(
  __in          PCTSTR RootPath,
  __in          PCTSTR InputPathName,
  __out         PTSTR OutputPathBuffer
);

Parameters

RootPath

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

InputPathName

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

OutputPathBuffer

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

Requires DbgHelp.dll 5.1 or later.

Header

Declared in Dbghelp.h.

Library

Use Dbghelp.lib.

DLL

Requires Dbghelp.dll.

Unicode

Implemented as SearchTreeForFileW (Unicode) and SearchTreeForFile (ANSI).

See Also

DbgHelp Functions

Send comments about this topic to Microsoft

Build date: 9/25/2007

© 2007 Microsoft Corporation. All rights reserved.