c++ - 在延迟的自定义操作中获取 CustomActionData

标签 c++ windows-installer custom-action

我尝试从 C++ dll 中的 CustomActionData 属性获取数据,但在延迟序列期间它始终为空。如果我在 UI 序列期间执行的 CA 中使用完全相同的代码,一切都会很好。

        UINT iCASize = 0;
        UINT uiStat = MsiGetProperty(hInstall, TEXT("CustomActionData"), TEXT(""), &iCASize);
        if (uiStat == ERROR_MORE_DATA)
        {
            // this means there are data to read. Allocate array for all data and read it (+1 for null termination)
            pCustData = new WCHAR[iCASize + 1];
            uiStat = MsiGetProperty(hInstall, TEXT("CustomActionData"), pCustData, &iCASize);
        }

你们中有人知道哪里出了问题吗?

最佳答案

要么是这个 C++ 代码有问题(我已经 20 年没用过 C++ 了),要么更可能是你没有正确设置 CustomActionData。

您需要在延迟的自定义操作之前在即时上下文中安排一个自定义操作。它设置的属性是延迟 CA 的名称。

Customaction 名称:SetSomething 属性:Something = Value:FOO(不是 CustomActionData = FOO)

自定义名称:Something MsiGetProperty( ... "CustomactionData"... );

关于c++ - 在延迟的自定义操作中获取 CustomActionData,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47811341/

相关文章:

WiX - 通过检查修订防止降级

c++ - WiX c++::在延迟 ca 中使用 dll 条目的正确方法

wix - 使用提升的权限但不作为 LocalSystem 调用自定义操作

c++ - C++ 中的 Unicode 问题,但不是 C

c++ - std vector 在访问未初始化的元素时不会抛出 out_of_range 异常

c++ - 围绕变量 "name"的堆栈已损坏 C++

c# - 自定义msiexec进度条?

c++ - 在 std::string 和 std::wstring 之间转换的多平台方式

windows - 名称为 "Uninstall <Program Name>"的快捷方式在 Windows 8/8.1/10 中不显示

c# - Wix:自定义操作可以走多远?