unit Unit1;
interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls; type TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm}////网友修改后 function GetFileSize(const FileName: string): Int64; var SR: TSearchRec; begin Result := -1; if FindFirst(FileName, faAnyFile and (not faDirectory), SR) = 0 then try Result := SR.Size; finally FindClose(SR); end; end; //万老师 原函数 function GetExeSize: Int64; var SearchRec: TSearchRec; begin Result := -1; if FindFirst(Application.ExeName, faAnyFile, SearchRec) = 0 then Result := SearchRec.Size; end; procedure TForm1.FormCreate(Sender: TObject); begin Edit1.Text:= ‘万一的方法结果:‘ + IntToStr(getExesize); Edit2.Text:= ‘在野修正后结果:‘ + IntToStr(GetFileSize(Application.ExeName)); end; end.
时间: 2024-12-25 14:24:55