mirror of
https://github.com/keymanapp/keyman.git
synced 2026-10-11 00:17:28 +00:00
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.
40 lines
895 B
ObjectPascal
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.
|