Windows 无法在“中设置/获取INSTALLDIR属性”;InstallscriptMSI";类型项目

Windows 无法在“中设置/获取INSTALLDIR属性”;InstallscriptMSI";类型项目,windows,installshield,Windows,Installshield,尝试使用MsiSetProperty/MsiGetProperty方法设置/获取INSTALLDIR属性。但它在InstallscriptMSI项目中不起作用。我错过了什么 在另一个论坛中发现,Installshield属性在某些情况下访问受限。注意: // Include header file for built-in functions #include "isrt.h" // Include header file for MSI API functions and consta

尝试使用MsiSetProperty/MsiGetProperty方法设置/获取INSTALLDIR属性。但它在InstallscriptMSI项目中不起作用。我错过了什么

在另一个论坛中发现,Installshield属性在某些情况下访问受限。

注意:

// Include header file for built-in functions 

#include "isrt.h" 

// Include header file for MSI API functions and constants 

#include "iswi.h"
export prototype Func1(HWND);
function Func1(hMSI)
STRING svName;
NUMBER nvSize, nResponse; 

begin 

// Retrieve the user's name from the MSI database 

nvSize = 256; 

MsiGetProperty (hMSI, "USERNAME", svName, nvSize); 



nResponse = AskYesNo ("Your name will be registered as " + 

                     svName + ". Is this correct?", YES); 


if nResponse = NO then 

    AskText ("Enter the name that will be registered for " + 

             "this product.", svName, svName); 

    MsiSetProperty(hMSI, "USERNAME", svName); 

endif; 

end; 
MsiGetProperty和MsiSetProperty属性不能用于延迟的InstallScript自定义操作,这些操作无权访问活动的.msi数据库,并且无法识别任何Windows Installer属性。它们只能访问写入执行脚本的信息

示例:

// Include header file for built-in functions 

#include "isrt.h" 

// Include header file for MSI API functions and constants 

#include "iswi.h"
export prototype Func1(HWND);
function Func1(hMSI)
STRING svName;
NUMBER nvSize, nResponse; 

begin 

// Retrieve the user's name from the MSI database 

nvSize = 256; 

MsiGetProperty (hMSI, "USERNAME", svName, nvSize); 



nResponse = AskYesNo ("Your name will be registered as " + 

                     svName + ". Is this correct?", YES); 


if nResponse = NO then 

    AskText ("Enter the name that will be registered for " + 

             "this product.", svName, svName); 

    MsiSetProperty(hMSI, "USERNAME", svName); 

endif; 

end; 

Vikky,假设我想通过编程将INSTALLDIR设置为非默认目标文件夹。显然,脚本无法识别该属性。如何解决此问题?@iManiac use szsdkddirectory=PROGRAMFILES^“companyfoldername\\productname”;nResult=SdAskDestPath(szTitle,“,szsdkddirectory,0);如果(szSDKDirectory!=PROGRAMFILES^“companyfoldername\\productname”),则szSDKDirectory=szSDKDirectory^“companyfoldername\\productname”;endif;最后设置这个INSTALLDIR=szsdkddirectory;我真的很抱歉,忘记提了。我正在尝试在升级期间设置属性。您的上一条注释已经实现,这是在正常安装期间。升级意味着维护模式?当维护标志为TRUE时,在OnShowUI()函数中调用OnMaintUIBefore()函数。在OnMaintUIBefore()函数中,调用nType=SdWelcomeMaint(szTitle、szMsg、nType);如果(nResult=NEXT),则转到Dlg_启动;endif//Dls_Start是在ShowDialogs()函数的前面定义的标签