Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wix 如何将捆绑负载的路径传递给msi?_Wix_Installation_Bootstrapper_Burn - Fatal编程技术网

Wix 如何将捆绑负载的路径传递给msi?

Wix 如何将捆绑负载的路径传递给msi?,wix,installation,bootstrapper,burn,Wix,Installation,Bootstrapper,Burn,我正在使用wix/burn创建一些MSI文件的引导程序。 我使用xml负载创建了标记: <BootstrapperApplicationRef ...> <Payload Id="myXML" Compressed="yes" SourceFile="c:\my.xml" /> </BootstrapperApplicationRef> 问题:如何将此有效负载的路径传递到MSI包 <MsiPackage ...> <MsiP

我正在使用wix/burn创建一些MSI文件的引导程序。 我使用xml负载创建了标记:

<BootstrapperApplicationRef ...>
    <Payload Id="myXML" Compressed="yes" SourceFile="c:\my.xml" />
</BootstrapperApplicationRef>
问题:如何将此有效负载的路径传递到MSI包

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

我还对在将文件传递给msi之前编辑该文件感兴趣。为此,我使用bafunctions.dll。但是我不知道如何获得C++的代码。我尝试了GetModuleFileName,但它提供了原始捆绑包路径,如c:\users\alex\desktop\bundle.exe,而不是所有内容都解压缩的临时文件夹。

我实际上找到了一种方法:

在bafunction.dll中,我们可以使用GetModuleFileName获取实际加载的dll的路径,而不是exe:

//define this in your compilation unit (cpp)
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
然后编写一个函数以获取dll路径:

WCHAR   DllPath[MAX_PATH] = {0};
GetModuleFileNameW((HINSTANCE)&__ImageBase, DllPath, _countof(DllPath));
这将为您提供bafunctions.dll的完整路径,但其他有效负载位于同一文件夹中。所以这只是解析这个字符串的问题

获得路径后,您可以创建自己的burn变量,该变量也可以在xml标记中引用

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