【问题标题】:Using C++ DLL in Installscript Custom Action在 Installscript 自定义操作中使用 C++ DLL
【发布时间】:2019-03-10 15:23:48
【问题描述】:

你好 Stackoverflow 社区,

我在 Installscript 自定义操作中调用 C++ DLL 时遇到问题。当我尝试使用参数调用我的 DLL 时,就会出现问题。错误图像如下所示:

  1. 使用参数调用 DLL

  2. 值、参数在 DLL 中已成功处理(值也已成功传输)

  3. DLL方法成功完成后,没有返回值,但设置失败,错误1603。

但是,如果我在没有参数的情况下调用相同的方法,则一切正常。

传递哪些参数或传递多少参数无关紧要。只要只传递一个参数,设置就会失败。

安装脚本:

prototype NUMBER DoSomeThing(HWND, STRING, INT);
prototype NUMBER MsiCppTest.DoSomethingInCpp(STRING, INT);
prototype NUMBER MsiCppTest.DoSomethingOtherInCpp();

function NUMBER DoSomething(hMSi, sText, nCount)
    STRING sSupportDir;
    NUMBER nSize, nResult, nValue;
begin
    nSize = 256;
    nValue = -1;
    MsiGetProperty(hMSi, "SUPPORTDIR", sSupportDir, nSize);
    nResult = UseDLL(sSupportDir ^ "MsiCppTest.dll");    
    if (nResult = 0) then
        //does not work:
        nValue = MsiCppTest.DoSomethingInCpp(sText, nCount);

        //would work:
        nValue = MsiCppTest.DoSomethingOtherInCpp();

        UnUseDLL(sSupportDir ^ "MsiCppTest.dll");
    endif;

    return nValue;
end; 

C++ DLL:

int DoSomethingInCpp(LPCTSTR lpText, int nCount) {
    //The ToDo function is executed successfully with the correct values
    ToDo(lpText, nCount);
    //As soon as the function is completed, the setup is aborted
    return 123;
}

int DoSomethingOtherInCpp() {
    //would work
    ToDo();
    return 321;
}

有没有人想办法解决这个问题?

【问题讨论】:

  • 您找到解决方案了吗?

标签: c++ dll windows-installer installshield installscript


【解决方案1】:

我对确切的症状和原因的细节有点生疏,但我怀疑这可能是 WINAPI / stdcallcdecl 调用约定不匹配。尝试将WINAPISTDCALL(或__stdcall)添加到您的c++ 函数声明中,或者将cdecl 添加到您的InstallScript 原型中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多