Windows installer InnoSetup MsiQueryProductState

Windows installer InnoSetup MsiQueryProductState,windows-installer,installation,setup-project,inno-setup,Windows Installer,Installation,Setup Project,Inno Setup,我想用Inno设置替换VS设置。请检查是否安装了旧版本。我找到了“MsiQueryProductState”方法。 我发现几个例子如下所示: function MsiQueryProductState(ProductCode: string): integer; external 'MsiQueryProductStateA@msi.dll stdcall'; function MsiConfigureProduct(ProductCode: string; iInstallLevel:

我想用Inno设置替换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\u默认值)

我发现了错误,我会把它贴出来作为答案


感谢Freddy,问题在于InnoSetup的Unicode版本与function prototype的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';

如果你自己找到了解决方案,你应该将其作为答案发布。几个小时后,你就可以把它标记为接受了。+1,我用一个小技巧扩展了你的答案(最初是由创建的)。如果您不喜欢我的编辑,可以查看我的编辑并选择回滚吗?谢谢