使用Installshield Installscript的MsiGetProperty字符串太长 [英] string too long with MsiGetProperty with Installshield Installscript

查看:308
本文介绍了使用Installshield Installscript的MsiGetProperty字符串太长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MsiGetProperty从安装程序获取字符串参数值. 然后,我调用托管的dll,并传递该值:

I am using MsiGetProperty to get string parameter value from the installer. And after that I am calling a managed dll and I pass the that value:

  nvBufferSize = MAX_STRING;
  MsiGetProperty (hMSI, "DBHMS", sDbHost, nvBufferSize);  

当我从托管代码接收到sDbHost的值时,它是这样的: srvdata-02NULNULNULNULNULNUL ...... 但是在界面中,我只写了"srvdata-02".

when I pass the value of sDbHost is like this when I receive it from managed code: srvdata-02NULNULNULNULNULNUL...... however in the interface I wrote just "srvdata-02".

使用相同的代码,Installshield 2010很好,现在我将其升级到installshield 2012. 请问您有什么解决办法吗?

With that same code it was fine with Installshield 2010, now I am upgrading it to installshield 2012. Do you have any solution with that please?

推荐答案

不久前,MsiGetProperty发生了一些行为更改.尝试将nvBufferSize设置为MAX_SIZE而不是MAX_STRING.还要检查MsiGetProperty的返回代码,以查看它是否等于ERROR_MORE_DATA或是否正在返回其他代码.最后检查nvBufferSize的值以查看需要多少字节.

There were some behavior changes to MsiGetProperty awhile back. Try setting nvBufferSize to MAX_SIZE instead of MAX_STRING. Also check the return code of MsiGetProperty to see if it equals ERROR_MORE_DATA or if it's returning some other code. Finally check the value of nvBufferSize to see how many bytes are needed.

顺便说一句,如果您只是想将属性封送给托管代码,则可能需要考虑研究Windows Installer XML(WiX)中的Deployment Tools Framework(DTF).这是一个非常不错的SDK,可让您编写托管代码自定义操作并将其打包,就好像它们是本机Win32库一样.然后,InstallShield可以轻松地将其用作MSI DLL自定义操作.

BTW, if you are just trying to marshal a property over to managed code, you might want to conisder looking into Deployment Tools Framework (DTF) in Windows Installer XML (WiX). This is a very nice SDK that allows you to write managed code custom actions and package them up as if they are native Win32 libraries. InstallShield can then easily use this as an MSI DLL custom action.

DTF提供了一个互操作库和一个会话对象,可以像下面这样使用:

DTF provides an interop library and a session object that can be used like:

  • Deployment Tools Foundation (DTF) Managed Custom Actions
  • Reasons DTF is Better

这篇关于使用Installshield Installscript的MsiGetProperty字符串太长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆