unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> function GetFileSize(const FileName: string): LongInt;<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>function TForm1.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>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> i:integer;<br>begin<br> i:=self.GetFileSize('c:/windows/desktop/ss.bmp');<br> showmessage(inttostr(i));<br>end;<br><br>end.<br>同意zw84611.