How to pass the path to a bundle's payload to an msi?

自闭症网瘾萝莉.ら 提交于 2019-12-11 16:24:10

问题


I am using wix/burn to create a bootstrapper to some MSI files. I created markup with an xml payload:

<BootstrapperApplicationRef ...>
    <Payload Id="myXML" Compressed="yes" SourceFile="c:\my.xml" />
</BootstrapperApplicationRef>

Question: How do I pass this payload's path to an MsiPackage?

<MsiPackage ...>
    <MsiProperty Name="XMLFILE" Value="[what do I use?]" />
</MsiPackage>

I'm also interested in editing the file before passing it to the msi. For that I'm using bafunctions.dll. But I don't know how to get the payload's path for bafunctions.dll either (c++ code). I tryed GetModuleFileName() but that gives me the original bundle path, like c:\users\alex\desktop\bundle.exe, not the temp folder where everything is unzipped.


回答1:


I actually found a way to do it:

in the bafunction.dll, we can use GetModuleFileName() to get the path of the actual loaded dll, not the exe:

//define this in your compilation unit (cpp)
EXTERN_C IMAGE_DOS_HEADER __ImageBase;

Then write a function to get the dll path:

WCHAR   DllPath[MAX_PATH] = {0};
GetModuleFileNameW((HINSTANCE)&__ImageBase, DllPath, _countof(DllPath));

That will give you the full path to bafunctions.dll, but other payloads are in the same folder. So it's just a matter of parsing this string.

After you get the path you can create a burn variable of your own that can be referenced in the xml markup as well.

hr = m_pEngine->SetVariableString(L"MyXmlPath", myxmlpath.c_str());
BalExitOnFailure(hr, "Failed to set variable MyXmlPath.");


来源:https://stackoverflow.com/questions/33243742/how-to-pass-the-path-to-a-bundles-payload-to-an-msi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!