它是关于Window COM组件的。
Server.exe:32位进程外COM服务器
CLSID_Application:Server.exe中COM对象的GUID
Client.exe:64位客户端应用程序,它以免注册方式使用Server.exe。
众所周知,exe不能用作免注册的COM组件,为了模仿这种行为,我通过提供确切路径亲自启动Server.exe进程:
CreateProcess(“ Server.exe”)
IClassFactory * pFactory = CoGetClassObject(CLSID_Application)
pFactory-> CreateInstance(ppAppObject);
如果我已经注册了Server.tlb,它可以工作,但是取消注册Server.tlb之后,即使我将清单嵌入到Server.exe和Client.exe中,它也无法创建ppAppObject:
<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>
<comInterfaceExternalProxyStub name="IApplication" iid="{D74208EA-71C2-471D-8681-9760B8ECE599}" tlbid="{DAC4A4C9-F84C-4F05-A7DC-E152869499F5}" proxyStubClsid32="{00020424-0000-0000-C000-000000000046}"></comInterfaceExternalProxyStub>
</assembly>
你对此有什么想法吗?
编辑:
事实证明,如果我为接口指定tlbid并将清单嵌入到两个exe中,则它确实有效
最佳答案
<comInterfaceExternalProxyStub>
元素是否足够?您还不需要<comClass>
和<typelib>
元素吗?