On some of my Windows 10 machines, FindFirstFile
matches files that definitely should not match. Assume the following program in Delphi:
{$apptype console}
uses Windows;
var
FindHandle: THandle;
FindData: WIN32_FIND_DATA;
begin
FindHandle := FindFirstFile('*.qqq', FindData);
if FindHandle <> INVALID_HANDLE_VALUE then
begin
try
repeat
Writeln(PChar(@FindData.cFileName[0]));
until not FindNextFile(FindHandle, FindData);
finally
FindClose(FindHandle);
end;
end;
end.
and four files:
a.qqq
b.qqqt
c.qqqx
c.qqq123
The output I expect to get is just a.qqq
. But what actually happens is, all four files get printed out. I get the same result with CMD's dir *.qqq
, too, so it's not just Delphi doing weird stuff, but PowerShell's dir *.qqq
works as expected. What could possibly be causing this behavior? And particularly, if it is some specific settings in the OS (which seems to be indicated by the fact that I don't get this result on all machines, just some), is there something I can do from within my program to enforce the expected behavior regardless of the OS settings?