我有个例子,你看看<br>unit Unit1;<br>interface<br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, ExtCtrls, StdCtrls, ComCtrls, TabNotBk, Buttons;<br>type<br> TfrmMain = class(TForm)<br> OpenDialog: TOpenDialog;<br> TabbedNotebook1: TTabbedNotebook;<br> Shape1: TShape;<br> Shape2: TShape;<br> BtnClose: TBitBtn;<br> Label1: TLabel;<br> ReadOnly: TCheckBox;<br> Hidden: TCheckBox;<br> Archive: TCheckBox;<br> System: TCheckBox;<br> lblPosition: TLabel;<br> lblSize: TLabel;<br> lblName: TLabel;<br> procedure FormCreate(Sender: TObject);<br> function GetFileSize(const FileName: string): LongInt;<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> frmMain: TfrmMain;<br> Attributes: Word;<br> NewAttributes: Word;<br> FileName:String;<br><br>implementation<br>{$R *.dfm}<br><br>procedure TfrmMain.FormCreate(Sender: TObject);<br>begin<br> if OpenDialog.Execute then<br> begin<br> FileName:= OpenDialog.FileName;<br> Attributes := FileGetAttr(FileName);<br> ReadOnly.Checked := (Attributes and faReadOnly) = faReadOnly;<br> Archive.Checked := (Attributes and faArchive) = faArchive;<br> System.Checked := (Attributes and faSysFile) = faSysFile;<br> Hidden.Checked := (Attributes and faHidden) = faHidden;<br><br> lblPosition.Caption:= lblPosition.Caption+ExtractFileDir(FileName);<br> lblName.Caption:=lblName.Caption+ExtractFileName(FileName);<br> lblSize.Caption:=lblSize.Caption+Format('%d bytes', [GetFileSize(FileName)]);<br> end;<br>end;<br><br>function TfrmMain.GetFileSize(const FileName: string): LongInt;<br>var<br> SearchRec: TSearchRec;<br>begin<br> try<br> if FindFirst(ExpandFileName(FileName), faAnyFile, SearchRec) = 0 then<br> Result := SearchRec.Size<br> else Result := -1;<br> finally<br> SysUtils.FindClose(SearchRec);<br> end;<br>end;<br><br>end.