windows-installer – InnoSetup MsiQueryProductState

前端之家收集整理的这篇文章主要介绍了windows-installer – InnoSetup MsiQueryProductState前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想用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';

猜你在找的Windows相关文章