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

📄 unit1.pas

📁 《Delphi 7应用编程150例》源码(全)
💻 PAS
字号:
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, ComCtrls, TabNotBk, Buttons;
type
  TfrmMain = class(TForm)
    OpenDialog: TOpenDialog;
    TabbedNotebook1: TTabbedNotebook;
    Shape1: TShape;
    Shape2: TShape;
    BtnClose: TBitBtn;
    Label1: TLabel;
    ReadOnly: TCheckBox;
    Hidden: TCheckBox;
    Archive: TCheckBox;
    System: TCheckBox;
    lblPosition: TLabel;
    lblSize: TLabel;
    lblName: TLabel;
    procedure FormCreate(Sender: TObject);
    function GetFileSize(const FileName: string): LongInt;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;
  Attributes: Word;
  NewAttributes: Word;
  FileName:String;

implementation
{$R *.dfm}

procedure TfrmMain.FormCreate(Sender: TObject);
begin
    if OpenDialog.Execute then
    begin
        FileName:= OpenDialog.FileName;
        Attributes := FileGetAttr(FileName);
        ReadOnly.Checked := (Attributes and faReadOnly) = faReadOnly;
        Archive.Checked := (Attributes and faArchive) = faArchive;
        System.Checked := (Attributes and faSysFile) = faSysFile;
        Hidden.Checked := (Attributes and faHidden) = faHidden;

        lblPosition.Caption:= lblPosition.Caption+ExtractFileDir(FileName);
        lblName.Caption:=lblName.Caption+ExtractFileName(FileName);
        lblSize.Caption:=lblSize.Caption+Format('%d bytes', [GetFileSize(FileName)]);
    end;
end;

function TfrmMain.GetFileSize(const FileName: string): LongInt;
var
  SearchRec: TSearchRec;
begin
  try
    if FindFirst(ExpandFileName(FileName), faAnyFile, SearchRec) = 0 then
      Result := SearchRec.Size
    else Result := -1;
  finally
    SysUtils.FindClose(SearchRec);
  end;
end;

end.

⌨️ 快捷键说明

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