function ShowVersion:String // 获得应用程序的版本号
var
VerInfo : PChar
lpTranslate : PLANGANDCODEPAGE
FileName:String
VerInfoSize, VerSize, cbTranslate : DWORD
VerValueSize : DWORD
Data 纳樱: String
VerFileV:PChar
lpFileVersion:string
begin
Result := '0.0.0.0'
FileName := Application.ExeName // 应用程序对应的 exe 文件
VerInfoSize := GetFileVersionInfoSize(PChar(FileName),VerSize)
if VerInfoSize > 0 then
begin
VerInfo := AllocMem(VerInfoSize)
GetFileVersionInfo(PChar(FileName),0,VerInfoSize,VerInfo)
VerQueryValue(VerInfo, PChar('/VarFileInfo/Translation'), Pointer(lpTranslate),cbTranslate)
if cbTranslate <> 0 then
begin
Data := format('/StringFileInfo/%.4x%.4x/FileVersion',[lpTranslate^.wLanguage,lpTranslate^.wCodePage])
VerQueryValue(VerInfo, PAnsiChar(data),Pointer(VerFileV), 宏茄桥VerValueSize)
if VerValueSize <> 0 then
begin
SetString(lpFileVersion,VerFileV,VerValueSize-1)
Result:=lpFileVersion
end
end
FreeMem(VerInfo,VerInfoSize)
end
else
begin
Result:='0.0.0.0'
Application.MessageBox('获取文件版本信息时遇到致命错误,请重新打开软件。','错误蔽猛',MB_OK+MB_ICONSTOP)
Application.Terminate
end
end
function GetApplicationVersion:String // Added 取得程序团庆晌版本号var FileName:String
InfoSize,Wnd:DWORD
VerBuf:Pointer
VerInfo:^VS_FIXEDFILEINFO
begin
Result:='0.0.0.0'
FileName:=Application.ExeName
InfoSize:=GetFileVersionInfoSize(PChar(FileName),Wnd)
if InfoSize<>0 then
begin
GetMem(VerBuf,InfoSize)
try
if GetFileVersionInfo(PChar(FileName),Wnd,InfoSize,VerBuf) then
begin
VerInfo:=nil
VerQueryValue(VerBuf,'\塌锋'差空,Pointer(VerInfo),Wnd)
if VerInfo<>nil then Result:=Format('%d.%d.%d.%d',[VerInfo^.dwFileVersionMS shr 16,
VerInfo^.dwFileVersionMS and $0000ffff,
VerInfo^.dwFileVersionLS shr 16,
VerInfo^.dwFileVersionLS and $0000ffff])
end
finally
FreeMem(VerBuf,InfoSize)
end
end
end
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)