将清单文件移动到 dll?
我在我的应用程序中使用了第三方组件,该组件作为 COM 组件分发,或者可以使用 .manifest 文件进行引用.无论哪种方式,它都是使用 CoCreateInstance() 加载的.第三方组件所需的文件位于子文件夹中.组件开发人员告诉我在可执行文件的 Visual Studio 2010 设置(在Manifest"部分)中包含一个 .manifest 文件,并且加载组件没有问题.
I'm using a third party component in my application that is distributed either as a COM component, or can be referenced using a .manifest file. Either way it is loaded using CoCreateInstance(). The files needed for the third party component reside in a subfolder. The component developer told me to include a .manifest file in the Visual Studio 2010 settings (in the "Manifest" section) of the executable, and loading the component works without problems.
现在我只使用 DLL 中的第三方组件来封装第三方组件中使用的功能.我正在使用 LoadLibrary() 动态加载 DLL.使用该组件仍然有效,我可以从引用清单文件的 EXE 加载的 DLL 中使用该组件.
Now I'm using the third party component from a DLL only, to encapsulate the features used from the third party component. I'm loading the DLL dynamically, using LoadLibrary(). Using the component still works, I can use the component from within the DLL that is loaded by the EXE that has the manifest file referenced.
为了进一步将 EXE 与第三方组件分开,我也想将清单移动到 DLL 中,这是唯一使用组件的地方.这样,我想编写的每个新 EXE 都可以使用 DLL 并间接使用这些功能.现在,我必须将 mainfest 添加到每个新的 EXE,但我不想这样做.
To further separate the EXE from the third pary component, I'd like to move the manifest to the DLL, too, where is the only place the component is used. In this way every new EXE I'd like to write can use the DLL and indirectly use the features. For now, I have to add the mainfest to every new EXE, but I don't want to do that.
有没有办法将 EXE 使用的清单移动到 DLL 中?
Is there a way to move the manifest used by the EXE to a DLL?
推荐答案
你可以把manifest放到DLL中,但是它可能不会自动激活.您可能需要使用激活上下文 API 手动执行此操作.我认为很大程度上取决于清单的用途.我怀疑您正在尝试使用免注册 COM,但这只是猜测.
You can put the manifest in the DLL, but it may not be activated automatically. You may need to do that manually using the activation context API. I think a lot depends on what the manifest is being used for. I suspect you are trying to use registration free COM, but that's only a guess.
无论如何,这些链接可能对您很有用:
Anyway, these links may well be useful to you:
- RT_MANIFEST 资源和 ISOLATION_AWARE_ENABLED(张俊峰)
- 隔离组件 (MSDN)
相关文章