spiegel-keyman/windows/src/desktop/setup/Keyman.Setup.System.MsiUtils.pas
Marc Durdin d6290e6373 fix(windows): Show full version with tag in Setup
Fixes #4041.

Show the version with tier and build flags in Setup so that it is clear
which version of Keyman will be installed, as the Keyman version can be
distinct from the setup.exe version.

Constructs the version tag from version+stability data in the
UpdateCheckResponse and uses a new MSI property called VersionWithTag
for Windows Installers. Older MSIs will still show a.b.c.d versions
instead of the tagged version if they are checked locally (as opposed to
online), because the new VersionWithTag property will not be present.
2020-12-17 15:01:37 +11:00

40 lines
895 B
ObjectPascal

unit Keyman.Setup.System.MsiUtils;
interface
function GetMsiVersion(const Filename: string; var VersionWithTag: string): string;
implementation
uses
jwawintype,
jwawinbase,
jwawinerror,
jwamsi,
jwamsiquery;
function GetMsiVersion(const Filename: string; var VersionWithTag: string): string;
var
sz: DWord;
buf: array[0..64] of WideChar;
hProduct: MSIHANDLE;
begin
Result := '';
if MsiOpenPackageExW(PWideChar(Filename), MSIOPENPACKAGEFLAGS_IGNOREMACHINESTATE, hProduct) = ERROR_SUCCESS then
begin
sz := 64;
if MsiGetProductPropertyW(hProduct, 'ProductVersion', buf, @sz) = ERROR_SUCCESS then
Result := buf;
sz := 64;
if MsiGetProductPropertyW(hProduct, 'VersionWithTag', buf, @sz) = ERROR_SUCCESS then
VersionWithTag := buf;
if VersionWithTag = '' then
VersionWithTag := Result;
MsiCloseHandle(hProduct);
end;
end;
end.