I'm updating a program to Delphi XE7 from Delphi 2010. The code shown below has stopped working due I think to the need to adapt for unicode and to use GetFileVersionInfoW instead of GetFileVersionInfoSize.
Has anyone developed a more up-to-date version of the function I was using shown below? I can't find any examples so far on the web and I'm afraid that low level windows programming is a bit beyond me.
Thanks for any help!
Old Code Below No Longer works on Delphi XE2 and later: just returns 1.0.0.0
procedure GetBuildInfo(var V1, V2, V3, V4: Word);
{From Steve Schafer }
var
VerInfoSize: DWORD;
VerInfo: pointer;
VerValueSize: DWORD;
VerValue: PVSFixedFileInfo;
Dummy: DWORD;
begin
VerInfoSize := GetFileVersionInfoSize(PChar(ParamStr(0)), Dummy);
GetMem(VerInfo, VerInfoSize);
GetFileVersionInfo(PChar(ParamStr(0)), 0, VerInfoSize, VerInfo);
VerQueryValue(VerInfo, '\', pointer(VerValue), VerValueSize);
with VerValue^ do
begin
V1 := dwFileVersionMS shr 16;
V2 := dwFileVersionMS and $FFFF;
V3 := dwFileVersionLS shr 16;
V4 := dwFileVersionLS and $FFFF;
end;
FreeMem(VerInfo, VerInfoSize);
end;