How to use an out-of-process COM server without its tlb file
It is about Window COM component.
- Server.exe: an 32bit out-of-process COM server
- CLSID_Application: The GUID of a COM object in Server.exe
- Client.exe: a 64bit client application which use Server.exe in a registry-free way.
As we know, an exe can't be used as a registry-free COM component, to mimic such behavior, I start the Server.exe process myself by providing the exact path:
- CreateProcess("Server.exe")
- IClassFactory* pFactory = CoGetClassObject(CLSID_Application)
- pFactory->CreateInstance(ppAppObject);
It works if I have the Server.tlb registred, but after unregister Server.tlb, it just failed to create the ppAppObject, even though I embed manifest into both Server.exe and Client.exe:
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<file name="Server.tlb">
<typelib tlbid="{DAC4A4C9-F84C-4F05-A7DC-E152869499F5}" version="1.0" helpdir=""></typelib>
</file>
<comI开发者_如何学编程nterfaceExternalProxyStub name="IApplication" iid="{D74208EA-71C2-471D-8681-9760B8ECE599}" tlbid="{DAC4A4C9-F84C-4F05-A7DC-E152869499F5}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub>
</assembly>
Do you have any idea on this?
Edit: It turns out that it really works if I specify tlbid for interfaces, and embed the manifest to both exe
Is the <comInterfaceExternalProxyStub>
element sufficient? Don't you need the <comClass>
and <typelib>
elements as well?
精彩评论