Q: How to get an EXEs Version-Information:
A: (found on a Newsgroup from Glenn Hancock)
Yes it is and here is a function that we use. Try it out and it should
provide you the information your looking for. This function only gives you
the version which is what we are most concerned with…
Good luck,
[code lang=”delphi”]function GetVersion(filename : pchar) : pchar;
// changed due to Windows API name conflict MTB: 10-19-2000
// function GetVersion (filename : pchar) : pchar;
// changed back to getversion for testing MTB: 10-20-2000
const
TRANSLATION_INFO = ‘\\VarFileInfo\\Translation’;
var
Blank : DWORD;
FVersionInfo : PChar;
VersionNumber : PChar;
FVersionInfoSize : integer;
ResultLen : UInt;
lpdwhandle : DWord;
dwHandle : integer;
PTranslationTable: pointer;
stranslationkey : string;
begin
versionnumber := ”;
FVersionInfoSize := GetFileVersionInfoSize(FileName, lpdwhandle);
if FVersionInfoSize = 0 then
begin
FVersionInfo := nil;
end
else
begin
GetMem(FVersionInfo, FVersionInfoSize+1);
GetFileVersionInfo(FileName, dwHandle, FVersionInfoSize, FVersionInfo);
VerQueryValue(FVersionInfo, pchar(TRANSLATION_INFO), pTranslationTable,
ResultLen);
sTranslationKey := ‘\\StringFileInfo\\’+
IntToHex(LoWord(LongInt(pTranslationTable^)),4)+
IntToHex(HiWord(LongInt(pTranslationTable^)),4)+
‘\\’;
VerQueryValue(FVersionInfo, pchar(sTranslationKey+’FileVersion’),
pointer(VersionNumber), ResultLen);
end;
FreeMem (FVersionInfo, FVersionInfoSize + 1);
FVersionInfo := nil;
result := VersionNumber;
end;
[/code]
[tags]Delphi, System, Files[/tags]
0 Kommentare zu “Get an EXEs Version-Information”