Windows Mobile 6.5
A version of this page is also available for

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).

HANDLE FindFirstFile(
  LPCTSTR lpFileName, 
  LPWIN32_FIND_DATA lpFindFileData 


[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.


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

A search handle, used in a subsequent call to the FindNextFile or the FindClose function indicates success. INVALID_HANDLE_VALUE indicates failure. To get extended error information, call GetLastError.

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.

Windows Embedded CEWindows CE 1.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions