⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exenumfu.pas

📁 条码控件: 一维条码控件 二维条码控件 PDF417Barcode MaxiCodeBarcode
💻 PAS
字号:
(* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is TurboPower SysTools
 *
 * The Initial Developer of the Original Code is
 * TurboPower Software
 *
 * Portions created by the Initial Developer are Copyright (C) 1996-2002
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * ***** END LICENSE BLOCK ***** *)

unit ExEnumFU;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    CheckBox1: TCheckBox;
    ListBox1: TListBox;
    Label1: TLabel;
    CheckBox2: TCheckBox;
    Button2: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    AList : TStringList;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses
  StConst,
  StBase,
  StSystem;

var
  StopIt : Boolean;

function ProcessAll(const SR : TSearchRec; ForInclusion : Boolean;
  var Abort : Boolean) : Boolean;
begin
  Abort := False;
  if StopIt then begin
    Abort := True;
    Result := False;
  end
  else begin
    Application.ProcessMessages;
    Result := True;
  end;
end;

function TextFilesOnly(const SR : TSearchRec; ForInclusion : Boolean;
  var Abort : Boolean) : Boolean;
var
  S : String;
begin
  Abort := False;
  if StopIt then begin
    Abort := True;
    Result := False;
  end
  else begin
    Application.ProcessMessages;

    if ForInclusion then begin
      Result := False;
      S := SR.Name;
      if (UpperCase(ExtractFileExt(S)) = '.TXT') or
         ((SR.Attr and faDirectory) > 0) then
        Result := True;
    end
    else
      Result := True;

  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  AList := TStringList.Create;
  Edit1.Text := 'C:\';
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  I : longint;
begin
  AList.Clear;
  ListBox1.Clear;

  Screen.Cursor := crHourGlass;
  StopIt := False;

  if not CheckBox2.Checked then begin
    EnumerateFiles(Edit1.Text, AList, CheckBox1.Checked, ProcessAll);
    ListBox1.Items := AList;
  end else begin
    EnumerateFiles(Edit1.Text, AList, CheckBox1.Checked, TextFilesOnly);
    {by its nature, EnumerateFiles also returns directory names}
    {remove those from the list - leaving only the text files}
    for I := 0 to AList.Count-1 do
      if (UpperCase(ExtractFileExt(AList[I])) = '.TXT') then
        ListBox1.Items.Add(AList[I]);
  end;

  Screen.Cursor := crDefault;
  ListBox1.Update;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  StopIt := True;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  AList.Free;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -