• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

取应用程式的版本号_Delphi

Delphi 搞代码 3年前 (2018-08-09) 118次浏览 已收录 0个评论

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 搞代码


喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址