November 25th, 2015

Clarifying the documentation on wildcards accepted by FindFirstFile/FindFirstFileEx

A customer asked for clarification in the documentation for Find­First­File and related functions, such as Find­First­File­Ex and Find­First­File­Transacted

Does Find­First­File­Ex support multiple wildcards in the lpFile­Name parameter? The documentation is not clear. We are hoping to pass something like C:\Directory1\Directory2\*abc*\def*.txt. Note that there are two asterisks in the directory portion as well as an asterisk in the file name portion. Should we expect this to work? The documentation is not very explicit about this scenario. It just says

lpFileName: The directory or path, and the file name, which can include wildcard characters, for example, an asterisk (*) or a question mark (?).

I agree that the documentation is ambiguous here. One interpretation of the sentence is

The directory or path, and the file name, any of which can include wildcard characters, for example, an asterisk (*) or a question mark (?).

Or it could be interpreted as

The directory or path, and the file name. The file name can include wildcard characters, for example, an asterisk (*) or a question mark (?).

You can have multiple wildcards, but all wildcards must exist in the file name portion. The search pattern lets you apply a filter to a search within a single directory. It is not a SQL query.

I submitted a documentation change request to clarify the sentence to the second version above:

The directory or path, and the file name. The file name can include wildcard characters, for example, an asterisk (*) or a question mark (?).

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.