我想用Inno Setup替换VS设置.检查是否安装了旧版本我找到了’MsiQueryProductState’方法.
我发现了几个看起来像这样的例子:
我发现了几个看起来像这样的例子:
function MsiQueryProductState(ProductCode: string): integer; external 'MsiQueryProductStateA@msi.dll stdcall'; function MsiConfigureProduct(ProductCode: string; iInstallLevel: integer; eInstallState: integer): integer; external 'MsiConfigureProductA@msi.dll stdcall'; const INSTALLSTATE_DEFAULT = 5; INSTALLLEVEL_MAXIMUM = $ffff; INSTALLSTATE_ABSENT = 2;
检查产品始终返回2而不是所需的5值(INSTALLSTATE_DEFAULT)
我发现了错误,我会将其作为答案发布……
谢谢弗雷迪
解决方法
问题是InnoSetup的Unicode版本与ANSI版本的函数原型混合在一起.用MsiQueryProductStateW替换MsiQueryProductStateA就足够了.
如果您使用此条件定义的脚本,InnoSetup编译预处理器将根据您使用ANSI或Unicode InnoSetup的时间找到函数(Unicode或ANSI)的正确版本.
[Code] #IFDEF UNICODE #DEFINE AW "W" #ELSE #DEFINE AW "A" #ENDIF function MsiQueryProductState(ProductCode: string): integer; external 'MsiQueryProductState{#AW}@msi.dll stdcall'; function MsiConfigureProduct(ProductCode: string; iInstallLevel: integer; eInstallState: integer): integer; external 'MsiConfigureProduct{#AW}@msi.dll stdcall';