Inno setup:根据产品代码检测安装
Inno setup: detect installation based on product code
我想实现类似于Inno setup - skip installation if other program is not installed
的东西
但我确实有 msiexec 产品代码(如 D3AA40C4-9BFB-4640-88CE-EDC93A3703CC)。那么如何根据这个产品代码检测是否安装了其他程序呢?
有 MsiQueryProductState
功能。这是它的导入,带有用于您的任务的辅助函数:
[Code]
#IFDEF UNICODE
#DEFINE AW "W"
#ELSE
#DEFINE AW "A"
#ENDIF
type
INSTALLSTATE = Longint;
const
INSTALLSTATE_DEFAULT = 5;
function MsiQueryProductState(szProduct: string): INSTALLSTATE;
external 'MsiQueryProductState{#AW}@msi.dll stdcall';
function IsProductInstalled(const ProductID: string): Boolean;
begin
Result := MsiQueryProductState(ProductID) = INSTALLSTATE_DEFAULT;
end;
及其可能的用法:
if IsProductInstalled('{D3AA40C4-9BFB-4640-88CE-EDC93A3703CC}') then
MsgBox('The product is installed.', mbInformation, MB_OK);
我想实现类似于Inno setup - skip installation if other program is not installed
的东西但我确实有 msiexec 产品代码(如 D3AA40C4-9BFB-4640-88CE-EDC93A3703CC)。那么如何根据这个产品代码检测是否安装了其他程序呢?
有 MsiQueryProductState
功能。这是它的导入,带有用于您的任务的辅助函数:
[Code]
#IFDEF UNICODE
#DEFINE AW "W"
#ELSE
#DEFINE AW "A"
#ENDIF
type
INSTALLSTATE = Longint;
const
INSTALLSTATE_DEFAULT = 5;
function MsiQueryProductState(szProduct: string): INSTALLSTATE;
external 'MsiQueryProductState{#AW}@msi.dll stdcall';
function IsProductInstalled(const ProductID: string): Boolean;
begin
Result := MsiQueryProductState(ProductID) = INSTALLSTATE_DEFAULT;
end;
及其可能的用法:
if IsProductInstalled('{D3AA40C4-9BFB-4640-88CE-EDC93A3703CC}') then
MsgBox('The product is installed.', mbInformation, MB_OK);