Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function searches a directory for a file or subdirectory with the specified file name.

A RAPI version of this function exists called CeFindFirstFile (RAPI).

Syntax

HANDLE FindFirstFile(
  LPCTSTR 
lpFileName, 
  LPWIN32_FIND_DATA 
lpFindFileData 
); 

Parameters

lpFileName

[in] Pointer to a null-terminated string that specifies a valid directory or path and file name, which can contain wildcard characters, such as an asterisk (*) or a question mark (?).

The default string size limit for paths is MAX_PATH characters. This limit is related to how this function parses paths.

lpFindFileData

[out] Pointer to the WIN32_FIND_DATAstructure that receives information about the found file or subdirectory.

Return Value

A search handle, used in a subsequent call to the FindNextFileor the FindClosefunction indicates success. INVALID_HANDLE_VALUE indicates failure. To get extended error information, call GetLastError.

Remarks

This function opens a search handle and returns information about the first file with the specified name. Once the search handle is established, use this function to search for other files that match the pattern. When the search handle is no longer needed, close it with FindClose.

This function searches for files by name only. It cannot be used for attribute-based searches.

Requirements

Header winbase.h
Library coredll.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also