FindFirstFileEx

Windows API

Synopsis

Finds the first file in a directory tree that matches the specified attributes and search criteria.

Parameters

FindFileData

A structure that receives information about the file.

lpFindFileData

A pointer to a FindFileData structure.

lpFindFileData

A pointer to a FindFileData structure.

dwFlags

Specifies the search criteria. See FindFirstFileEx for details.

dwFlags

Specifies the search criteria. See FindFirstFileEx for details.

lpName

A pointer to a null-terminated string specifying the name of the file to search for. This parameter is optional.

lpName

A pointer to a null-terminated string specifying the name of the file to search for. This parameter is optional.

Return Value

WIN_ERROR

If the function succeeds, returns 0. If the function fails, returns an error code.

WIN_ERROR

If the function succeeds, returns 0. If the function fails, returns an error code.

Example


                HANDLE hFile;
                DWORD dwError = 0;
                FindFileData fileInfo;

                hFile = FindFirstFileExW(
                    "C:\\MyFolder",
                    &fileInfo,
                    0,
                    &dwError
                );

                if (hFile == INVALID_HANDLE_VALUE)
                {
                    printf("FindFirstFileEx failed with error code: %ld\n", dwError);
                }
                else
                {
                    printf("File found: %s\n", fileInfo.name);
                }

                FindClose(hFile);