如何从 MSI/WIX 项目中的 DLL 自定义操作 (C++ DLL) 访问临时 Exe 或 DLL?
我有两个用例:1)在自定义操作期间加载临时 DLL,2)从自定义操作执行临时 EXE。自定义操作 DLL 是非托管 C++。我不知道如何让它正常工作。包含 DLL 很容易,但 LoadLibrary 失败,因为它找不到 DLL。我似乎也无法获取提取的 DLL 的物理路径,以便在 LoadLibrary 中指定完整路径。任何帮助表示赞赏。顺便说一句,我正在使用 WIX 来完成这项工作。
I have two use cases: 1) loading a temporary DLL during a custom action and 2) executing a temporary EXE from a custom action. The custom action DLL is unmanaged C++. I cannot figure out how to get this working correctly. Including the DLL is easy enough but LoadLibrary is failing as it cannot find the DLL. I also cannot seem to get the physical path of the extracted DLL in order to specify full path in LoadLibrary. Any help is appreciated. I'm using WIX btw for this work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您已将 dll 和 exe 包含在 msi 的二进制表中,则这些文件将实际存在于当前登录用户的 %Temp% 文件夹中,该文件夹会映射到 Windows Installer 的 SUPPORTDIR 属性。
您需要使用 MsiGetProperty 获取 SUPPORTDIR 并在 LoadLibrary 中使用它。
If you have included the dll and the exe in the Binary Table of the msi, the files will be physically present in the %Temp% folder of the currently logged in user which gets mapped to SUPPORTDIR property of Windows Installer.
You need to use MsiGetProperty to get the SUPPORTDIR and use that in the LoadLibrary.
要记住的一件事 - Windows Installer 通常将文件从二进制表提取到 %TEMP%,但是 - 当前工作目录通常设置为 c:\windows\installer。
我的建议 - 当您需要时,自己从二进制表中提取临时 .dll。这使您可以控制何时保存。请记住,您需要对该位置的写入权限,因此通常 %temp% 的某个子目录是最佳选择。
One thing to remember - Windows Installer usually extracts files from Binary table to %TEMP%, however - the current work directory is often set to c:\windows\installer.
My suggestion - extract the temporary .dll from Binary table yourself when you need it. This gives you the control of when it's saved to. Just remember that you need write permission to the location, so usually some subdir of %temp% is the best choice.