> Can I get the Application Version, which I set using IDE’s option menu , in
> code? How?
Here’s an example:
[code lang=”delphi”]type
PTransBuffer = ^TTransBuffer;
TTransBuffer = array[1..4] of smallint;
const
CInfoStr : array[1..4] of string =
(‘FileVersion’,’LegalCopyright’, ‘ProductName’, ‘ProductVersion’);
procedure TFrmAbout.GetVersionInfo(AVersionList: TStrings);
var
filename: string;
i: integer;
infoSize: DWORD;
ptrans: PTransBuffer;
transStr: string;
typeStr: string;
value: PChar;
verBuf: pointer;
verSize: DWORD;
wnd: DWORD;
begin
AVersionList.Clear;
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
VerQueryvalue(verBuf, PChar(‘\VarFileInfo\Translation’),
Pointer(ptrans), verSize);
transStr := IntToHex(ptrans^[1], 4) + IntToHex(ptrans^[2], 4);
for i := Low(CInfoStr) to High(CInfoStr) do
begin
typeStr := ‘StringFileInfo\’ + transStr + ‘\’ + CInfoStr[i];
if VerQueryvalue(verBuf, PChar(typeStr),
Pointer(value), verSize) then
(*AVersionList.Add(CInfoStr[i] + ‘: ‘ + value);
*)
AVersionList.Add(value);
end
end;
finally
FreeMem(verBuf);
end;
end;
end;
[/code]
[tags]Delphi, Misc, Files[/tags]
0 Kommentare zu “How To Get VersionInformation”