取应用程式的版本号_Delphi

  • 内容
  • 评论
  • 相关

function GetAppVersion:String;
{取应用程式的版本号程式,如有版本号,返回值为版本号的值,否则返回值为空
返回值的格式为如1.0.0.0
胡国荣 2000/11/04 }
  function GetFileVersion(FileName: string): string;
  type
    PVerInfo = ^TVS_FIXEDFILEINFO;
    TVS_FIXEDFILEINFO = record
      dwSignature: longint;
      dwStrucVersion: longint;

http://www.gaodaima.com/65668.html取应用程式的版本号_Delphi

      dwFileVersionMS: longint;
      dwFileVersionLS: longint;
      dwFileFlagsMask: longint;
      dwFileFlags: longint;
      dwFileOS: longint;
      dwFileType: longint;
      dwFileSubtype: longint;
      dwFileDateMS: longint;
      dwFileDateLS: longint;
    end;
  var
    ExeNames: array[0..255] of char;
    zKeyPath: array[0..255] of Char;
    VerInfo: PVerInfo;
    Buf: pointer;
    Sz: word;
    L, Len: Cardinal;
  begin
    StrPCopy(ExeNames, FileName);
    Sz := GetFileVersionInfoSize(ExeNames, L);
    if Sz=0 then
    begin
      Result:='';
      Exit;
    end;

    try
      GetMem(Buf, Sz);
      try
        GetFileVersionInfo(ExeNames, 0, Sz, Buf);
        if VerQueryValue(Buf, '/', Pointer(VerInfo), Len) then
        begin
          Result := IntToStr(HIWORD(VerInfo.dwFileVersionMS)) + '.' +
                    IntToStr(LOWORD(VerInfo.dwFileVersionMS)) + '.' +
                    IntToStr(HIWORD(VerInfo.dwFileVersionLS)) + '.' +
                    IntToStr(LOWORD(VerInfo.dwFileVersionLS));

        end;
      finally
        FreeMem(Buf);
      end;
    except
      Result := '-1';
    end;
  end;
begin
  Result:=GetFileVersion(Application.ExeName);
end;

欢迎大家阅读《取应用程式的版本号_Delphi》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码

原创文章,转载请注明: 转载自搞代码

本文链接地址: 取应用程式的版本号_Delphi

微信支付二维码

微信 赏一包辣条吧~

支付宝支付二维码

支付宝 赏一听可乐吧~

评论

0条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注