我希望实现与Inno setup - skip installation if other program is not installed
类似的功能但我确实有msiexec产品代码(如D3AA40C4-9BFB-4640-88CE-EDC93A3703CC)。那么如何根据此产品代码检测是否安装了其他程序?
答案 0 :(得分:3)
此功能有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);