我正在开发两个不同的 C++ DLL 项目,它们共享大部分代码。因此,我有一个编译到的基础项目Base.lib和两个编译到Derived1.dll并Derived2.dll链接到Base.lib. 这些派生的 DLL 应独立发货。用户甚至不知道他们是相关的。
现在我希望我的两个 DLL 都是Windows 事件提供程序。我想记录的所有事件都发生在Base.lib. 因此,我Instrumentation.man在该项目中添加了一个并将其作为构建的一部分。它的内容大致是这样的:
<?xml version="1.0" encoding="UTF-16"?>
<instrumentationManifest xsi:schemaLocation="http://schemas.microsoft.com/win/2004/08/events eventman.xsd" xmlns="http://schemas.microsoft.com/win/2004/08/events" xmlns:win="http://manifests.microsoft.com/win/2004/08/windows/events" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:trace="http://schemas.microsoft.com/win/2004/08/events/trace">
<instrumentation>
<events>
<provider name="Company-Provider-Base" guid="{12345678-1234-1234-1234-1234567890ABCD}" symbol="provider" resourceFileName="some/path/to.dll" messageFileName="some/path/to.dll" message="$(string.provider.message)">
<events>
...
</events>
</provider>
</events>
</instrumentation>
<localization>
<resources culture="en-US">
<stringTable>
<string id="provider.message" value="Base Provider" />
...
</stringTable>
</resources>
</localization>
</instrumentationManifest>
我用mc.exe它编译成资源文件和头文件。头文件包含在我的 Base 项目的其他源文件中。
现在这个效果出奇的好!为这两个 DLL 正确记录所有事件。
但是,当然,现在两个 DLL 共享同一个提供程序,具有相同的名称、guid 和消息。
所以,我的实际问题是:
如何以我的 DLL 项目可以填充自己的 、 和 属性的方式使元素可provider定制?Instrumentation.mannameguidmessage
我正在使用 WiX 创建我的安装套件。仅当 DLL 部署在目标系统上时, WiX 允许我自定义元素的resourceFileName和messageFileName属性provider(两者都指向原始文件中的虚拟对象),以便可以正确引用它们。但是,WIX 没有提供类似的方式(至少我没有看到)来同样平滑地更改其他属性,这正是我想要的。
我还注意到 WiX 提供了自定义parameterFileName属性。不幸的是,我找不到这些参数如何工作的任何信息。我知道我可以放入%%n清单中的字符串,然后n将插入带有标识符的参数。但是我不明白在哪里以及如何声明这些参数,而且我不知道我是否可以在我想要自定义的属性中使用它们,这样它们根本不会帮助我。