FindFirst 无法找到扩展名为 ~1~ 和其他文件的所有文件

FindFirst cannot find all files with extension ~1~ and others

SysUtils.FindFirst 找不到扩展名为 ~1~ 和其他奇怪文件扩展名的所有文件,例如:Unit1.dfm.~1~

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TSearchRec sr;
  int iAttributes = 0;
  StringGrid1->RowCount = 1;
  iAttributes |= faReadOnly;
  iAttributes |= faHidden;
  iAttributes |= faSysFile;
  iAttributes |= faVolumeID;
  iAttributes |= faDirectory;
  iAttributes |= faArchive;
  iAttributes |= faAnyFile;
  StringGrid1->RowCount = 0;
  if (FindFirst(Edit1->Text, iAttributes, sr) == 0)
  {
    do
    {
      if ((sr.Attr & iAttributes) == sr.Attr)
      {
        StringGrid1->RowCount = StringGrid1->RowCount + 1;
        StringGrid1->Cells[1][StringGrid1->RowCount-1] = sr.Name;
        StringGrid1->Cells[2][StringGrid1->RowCount-1] = IntToStr(sr.Size);
      }
    } while (FindNext(sr) == 0);
    FindClose(sr);
  }
}

如何使这段代码找到所有文件,具有任何扩展名?

以下代码将显示目录中的所有项目,包括 ., .., .~* 文件 - 例如在 C++Builder 项目的历史文件夹中:D

我在编辑框中输入以下字符串:

C:\Users\david\Documents\Embarcadero\Studio\Projects\FindFirstVCLCpp\__history\*.*

TMemo 执行后包含以下内容:

. = 0
.. = 0
Unit1.cpp.~1~ = 991
Unit1.cpp.~2~ = 996

按钮处理程序的源代码:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  TSearchRec sr;
  Memo1->Lines->Clear();
  int iAttributes = 0;
  iAttributes |= faReadOnly;
  iAttributes |= faHidden;
  iAttributes |= faSysFile;
  iAttributes |= faVolumeID;
  iAttributes |= faDirectory;
  iAttributes |= faArchive;
  iAttributes |= faAnyFile;
  if (FindFirst(Edit1->Text, iAttributes, sr) == 0)
  {
    do
    {
      if ((sr.Attr & iAttributes) == sr.Attr)
      {
        Memo1->Lines->Add(
          sr.Name
          + " = "
          + IntToStr(sr.Size)
        );
      }
    } while (FindNext(sr) == 0);
    FindClose(sr);
  }
}