Created
June 12, 2013 08:19
-
-
Save den-kozlov/5763633 to your computer and use it in GitHub Desktop.
Get application version in Delphi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function GetApplicationVersion:string; | |
var | |
verblock:PVSFIXEDFILEINFO; | |
versionMS,versionLS:cardinal; | |
verlen:cardinal; | |
rs:TResourceStream; | |
m:TMemoryStream; | |
p:pointer; | |
s:cardinal; | |
begin | |
m:=TMemoryStream.Create; | |
try | |
rs:=TResourceStream.CreateFromID(HInstance,1,RT_VERSION); | |
try | |
m.CopyFrom(rs,rs.Size); | |
finally | |
rs.Free; | |
end; | |
m.Position:=0; | |
if VerQueryValue(m.Memory,'\',pointer(verblock),verlen) then | |
begin | |
VersionMS:=verblock.dwFileVersionMS; | |
VersionLS:=verblock.dwFileVersionLS; | |
Result:= IntToStr(versionMS shr 16)+'.'+ | |
IntToStr(versionMS and $FFFF)+'.'+ | |
IntToStr(VersionLS shr 16)+'.'+ | |
IntToStr(VersionLS and $FFFF); | |
end; | |
// if VerQueryValue(m.Memory,PChar('\\StringFileInfo\\'+ | |
// IntToHex(GetThreadLocale,4)+IntToHex(GetACP,4)+'\\FileDescription'),p,s) or | |
// VerQueryValue(m.Memory,'\\StringFileInfo\\040904E4\\FileDescription',p,s) then //en-us | |
// Result:=PChar(p)+' '+AppVersionString; | |
finally | |
m.Free; | |
end; | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment