Platform SDK: Win32 API |
You can search directories for selected files by using Find First File and Find Next File (Interrupt 21h Functions 714Eh and 714Fh). These functions search for and return information about files having long file names and aliases (file names in the standard 8.3 format). The functions return information in a WIN32_FIND_DATA structure, which contains both the file name and the corresponding alias, if any.
Unlike MS-DOS Find First File (Interrupt 21h Function 4Eh), the long file name version of Find First File allocates internal storage for the search operations and returns a handle that identifies the storage. This handle is used with Find Next File. To make sure the internal storage is freed, you must use Find Close (Interrupt 21h Function 71A1h) to end the search.
You pass the Delete File (Interrupt 21h Function 7141h) and Find First File functions a file name, which may contain wildcard characters, such as an asterisk (*) or question mark (?). Because Find First File, Find Next File, and Delete File examine long file names and aliases during the search, some wildcard searches may yield unexpected results. For example, if the system has generated the alias LONGFI~1 for the long file name LongFile name, a search for names that match the *1 pattern would always return the LongFile name file, even though that name does not end with a 1. Searches are not case-sensitive. For example, a search for names that match the *mid* pattern will yield the same results as that for the *MID* pattern. In general, you should check both names returned in the WIN32_FIND_DATA structure to determine which of them matched the pattern.
Wildcard searches are more flexible in Windows 95/98 than in MS-DOS. In the preceding examples, *1 finds the file names that end in a 1 and *mid* finds file names that contain the characters mid. In MS-DOS and in Windows 95/98 searching on real-mode FAT directories, all characters after the first * are ignored.