究竟如何配置 DCOM 将我的 DLL 加载到单独的进程中?
我试图强制现有的本机 C++ ATL 进程内 COM 服务器进入一个单独的进程。我希望 DCOM 能够在不改变 COM 服务器的情况下为我做到这一点。
我从通常的注册表设置开始 - 我有一个 HKCR\CLSID{classId} 条目和一个 InProcServer32 项,其中指定 .dll 文件的路径。
我生成了一个应用程序 ID (GUID) 并将其添加到各处。具体来说,我在 HKCR\CLSID{classId} 下添加了一个等于应用程序 ID 的字符串值“AppId”。我还添加了 HKCR\AppId{applicationId} 键和等于空字符串的字符串值“DllSurrogate”。我认为这足以强制我的 COM 服务器成为系统提供的默认代理。
DCOM 应用程序出现在 DCOM 配置控制台中。但是,当我调用 CoCreateInstance()
或 CoGetClassObject()
并提供类 id 和 CLSCTX_LOCAL_SERVER
时,它返回“类未注册”。我做错了什么?
UPD:已解决。所采取的步骤足以使其工作,只是我正在编辑错误的类 ID 的注册表,由于某种原因,该类 ID 在 InProcServer32 项下具有相同的路径 - 也许这是一个 COM 地狱问题。
I'm trying to force an existing native C++ ATL in-proc COM server into a separate process. I hope DCOM can do this for me without changing the COM server.
I started with a usual registry setup - I have a HKCR\CLSID{classId} entry and an InProcServer32 key there specifying the path to the .dll file.
I generated an application id (GUID) and added it here and there. Specifically I added a string value "AppId" under HKCR\CLSID{classId} equal to the application id. I also added a HKCR\AppId{applicationId} key and a string value "DllSurrogate" equal to an empty string. I thought it would be enough for forcing my COM server into a default system-provided surrogate.
The DCOM application appears in the DCOM configuration console. However when I call CoCreateInstance()
or CoGetClassObject()
and provide the class id and CLSCTX_LOCAL_SERVER
it returns "Class not registered". What am I doing wrong?
UPD: Resolved. The steps taken were enough to make it work except that I was editing the registry for the wrong class id that for some reason had the same path under InProcServer32 key - perhaps that was a COM hell issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
按照检查列表进行操作:
CLSCTX_LOCAL_SERVER
位已设置,并且 CLSID 键未指定 LocalServer32、LocalServer 或 LocalService。 (已选中)Follow the check list:
CLSCTX_LOCAL_SERVER
bit is set and the CLSID key does not specify LocalServer32, LocalServer, or LocalService. (checked)错误的注册表项。您需要在 HKCR\CLSID{classId} 中设置 LocalServer32,而不是 InProcServer32。
但是,Windows 无法实例化 DLL。因此,您需要将程序更改为完整的 COM 服务器 exe。 Windows 将启动您的 EXE 并发送参数 /embedding。然后您可以创建 CComModule 并启动您的程序。
wrong registry key. you need to set LocalServer32, not InProcServer32 in HKCR\CLSID{classId}.
However, windows cannot instantiate a DLL. So you need to change your program into a full COM server exe. Windows will start your EXE and send in the argument /embedding. You can then create the CComModule and start your program.
这不就是 DLLHOST.EXE 的用途吗?
Isn't this what DLLHOST.EXE was made for?