日本好好热aⅴ|国产99视频精品免费观看|日本成人aV在线|久热香蕉国产在线

  • <cite id="ikgdy"><table id="ikgdy"></table></cite>
    1. 西西軟件園多重安全檢測(cè)下載網(wǎng)站、值得信賴的軟件下載站!
      軟件
      軟件
      文章
      搜索

      首頁(yè)編程開發(fā)Delphi → delphi 中文件查找API函數(shù) findfirst,findnext,findclose 的使用

      delphi 中文件查找API函數(shù) findfirst,findnext,findclose 的使用

      前往專題相關(guān)軟件相關(guān)文章發(fā)表評(píng)論 來源:本站整理時(shí)間:2010/10/28 17:39:30字體大。A-A+

      作者:不詳點(diǎn)擊:1704次評(píng)論:0次標(biāo)簽: delphi

      Borland Delphi8.0光盤版
      • 類型:編程工具大小:83.1M語(yǔ)言:中文 評(píng)分:4.0
      • 標(biāo)簽:
      立即下載

      我們先來看一下需求.

      我們需要查找某一個(gè)目錄下面,體積最大的 exe 文件。

      可以用下面的函數(shù):

       K:=FindFirst(AppRootPath+'\*.exe',faAnyFile, vSearchRec);
          while K = 0 do
           begin
             if (AppRootFileName <>  vSearchRec.Name) and (i< vSearchRec.Size) then
             begin
              i:=vSearchRec.Size;
              AppName:= vSearchRec.Name;
             end;
             K:= FindNext(vSearchRec);
           end;

      這里用到了兩個(gè)函數(shù):

      FindFirst 是用來尋找目標(biāo)目錄下的第一個(gè)文件,
      FindFirst函數(shù)在delphi幫助下的定義:
      function FindFirst(const Path: string; Attr: Integer; var F: TSearchRec): Integer;
      其中有一句:FindFirst returns 0 if a file was successfully located
      也就是說,當(dāng)成功找到文件時(shí),返回0.
       
      Delphi syntax:

      function FindNext(var F: TSearchRec): Integer;

      FindNext 則是尋找下一個(gè)
      TSearchRec 是一個(gè)文件信息的紀(jì)錄,當(dāng)FindFirst返回SearchRec時(shí),你可以通過SearchRec.Name獲取文件名,以及 SearchRec.Size獲取文件大小等信息。

      The following example uses an edit control, a button, a string grid, and seven check boxes. The check boxes correspond to the seven possible file attributes. When the button is clicked, the path specified in the edit control is searched for files matching the checked file attributes. The names and sizes of the matching files are inserted into the string grid.

      procedure TForm1.Button1Click(Sender: TObject);

      var
      sr: TSearchRec;
      FileAttrs: Integer;
      begin
      StringGrid1.RowCount := 1;
      if CheckBox1.Checked then
      FileAttrs := faReadOnly
      else
      FileAttrs := 0;
      if CheckBox2.Checked then
      FileAttrs := FileAttrs + faHidden;
      if CheckBox3.Checked then
      FileAttrs := FileAttrs + faSysFile;
      if CheckBox4.Checked then
      FileAttrs := FileAttrs + faVolumeID;
      if CheckBox5.Checked then

      FileAttrs := FileAttrs + faDirectory;
      if CheckBox6.Checked then
      FileAttrs := FileAttrs + faArchive;
      if CheckBox7.Checked then

      FileAttrs := FileAttrs + faAnyFile;

      with StringGrid1 do
      begin
      RowCount := 0;

      if FindFirst(Edit1.Text, FileAttrs, sr) = 0 then

      begin
      repeat
      if (sr.Attr and FileAttrs) = sr.Attr then
      begin
      RowCount := RowCount + 1;
      Cells[1,RowCount-1] := sr.Name;
      Cells[2,RowCount-1] := IntToStr(sr.Size);
      end;
      until FindNext(sr) <> 0;
      FindClose(sr);
      end;
      end;
      end;

       

        相關(guān)評(píng)論

        閱讀本文后您有什么感想? 已有人給出評(píng)價(jià)!

        • 8 喜歡喜歡
        • 3 頂
        • 1 難過難過
        • 5 囧
        • 3 圍觀圍觀
        • 2 無聊無聊

        熱門評(píng)論

        最新評(píng)論

        發(fā)表評(píng)論 查看所有評(píng)論(0)

        昵稱:
        表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
        字?jǐn)?shù): 0/500 (您的評(píng)論需要經(jīng)過審核才能顯示)