[Microsoft strongly recommends developers utilize alternative means to achieve your application’s needs. Many scenarios that TxF was developed for can be achieved through simpler and more readily available techniques. Furthermore, TxF may not be available in future versions of Microsoft Windows. For more information, and alternatives to TxF, please see Alternatives to using Transactional NTFS.]
Searches a directory for a file or subdirectory with a name that matches a specific name as a transacted operation.
This function is the transacted form of the FindFirstFileEx function.
For the most basic version of this function, see FindFirstFile.
HANDLE FindFirstFileTransactedA( LPCSTR lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, LPVOID lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, LPVOID lpSearchFilter, DWORD dwAdditionalFlags, HANDLE hTransaction );
The directory or path, and the file name. The file name can include wildcard characters, for example, an asterisk (*) or a question mark (?).
This parameter should not be NULL, an invalid string (for example, an empty string or a string that is missing the terminating null character), or end in a trailing backslash ().
If the string ends with a wildcard, period (.), or directory name, the user must have access to the root and all subdirectories on the path.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\?" to the path. For more information, see Naming a File.
The file must reside on the local computer; otherwise, the function fails and the last error code is set to ERROR_TRANSACTIONS_UNSUPPORTED_REMOTE.
The information level of the returned data.
This parameter is one of the FINDEX_INFO_LEVELS enumeration values.
A pointer to the WIN32_FIND_DATA structure that receives information about a found file or subdirectory.
The type of filtering to perform that is different from wildcard matching.
This parameter is one of the FINDEX_SEARCH_OPS enumeration values.
A pointer to the search criteria if the specified fSearchOp needs structured search information.
At this time, none of the supported fSearchOp values require extended search information. Therefore, this pointer must be NULL.
Specifies additional flags that control the search.
||Searches are case-sensitive.|
A handle to the transaction. This handle is returned by the CreateTransaction function.
If the function succeeds, the return value is a search handle used in a subsequent call to FindNextFile or FindClose, and the lpFindFileData parameter contains information about the first file or directory found.
If the function fails or fails to locate files from the search string in the lpFileName parameter, the return value is INVALID_HANDLE_VALUE and the contents of lpFindFileData are indeterminate. To get extended error information, call the GetLastError function.
The FindFirstFileTransacted function opens a search handle and returns information about the first file that the file system finds with a name that matches the specified pattern. This may or may not be the first file or directory that appears in a directory-listing application (such as the dir command) when given the same file name string pattern. This is because FindFirstFileTransacted does no sorting of the search results. For additional information, see FindNextFile.
The following list identifies some other search characteristics:
- The search is performed strictly on the name of the file, not on any attributes such as a date or a file type.
- The search includes the long and short file names.
- An attempt to open a search with a trailing backslash always fails.
- Passing an invalid string, NULL, or empty string for the lpFileName parameter is not a valid use of this function. Results in this case are undefined.
After the search handle is established, use it in the FindNextFile function to search for other files that match the same pattern with the same filtering that is being performed. When the search handle is not needed, it should be closed by using the FindClose function.
As stated previously, you cannot use a trailing backslash () in the lpFileName input string for FindFirstFileTransacted, therefore it may not be obvious how to search root directories. If you want to see files or get the attributes of a root directory, the following options would apply:
- To examine files in a root directory, you can use "C:\*" and step through the directory by using FindNextFile.
- To get the attributes of a root directory, use the GetFileAttributes function.
To examine a directory that is not a root directory, use the path to that directory, without a trailing backslash. For example, an argument of "C:\Windows" returns information about the directory "C:\Windows", not about a directory or file in "C:\Windows". To examine the files and directories in "C:\Windows", use an lpFileName of "C:\Windows*".
Be aware that some other thread or process could create or delete a file with this name between the time you query for the result and the time you act on the information. If this is a potential concern for your application, one possible solution is to use the CreateFile function with CREATE_NEW (which fails if the file exists) or OPEN_EXISTING (which fails if the file does not exist).
If you are writing a 32-bit application to list all the files in a directory and the application may be run on a 64-bit computer, you should call Wow64DisableWow64FsRedirection before calling FindFirstFileTransacted and call Wow64RevertWow64FsRedirection after the last call to FindNextFile. For more information, see File System Redirector.
If the path points to a symbolic link, the WIN32_FIND_DATA buffer contains information about the symbolic link, not the target.
In Windows 8 and Windows Server 2012, this function is supported by the following technologies.
|Server Message Block (SMB) 3.0 protocol||No|
|SMB 3.0 Transparent Failover (TFO)||No|
|SMB 3.0 with Scale-out File Shares (SO)||No|
|Cluster Shared Volume File System (CsvFS)||No|
|Resilient File System (ReFS)||No|
SMB 3.0 does not support TxF.
|Windows version||Windows Vista [desktop apps only] Windows Server 2008 [desktop apps only]|
|Header||winbase.h (include Windows.h)|