• 获取程序自身大小的2个函数


     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.
  • 相关阅读:
    初学者常用的LINUX命令
    logging模块全总结
    logging模块初识
    xpath知多少
    selenium常用的API
    系统测试基础(适合入门)
    JavaScript正则表达式(一)
    webpack2学习(二)
    webpack2学习(一)
    SQL语句学习
  • 原文地址:https://www.cnblogs.com/tmdsleep/p/4539815.html
Copyright © 2020-2023  润新知