究竟如何配置 DCOM 将我的 DLL 加载到单独的进程中?

发布于 2024-08-10 03:52:39 字数 636 浏览 1 评论 0原文

我试图强制现有的本机 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

四叶草在未来唯美盛开 2024-08-17 03:52:39

按照检查列表进行操作

  1. 必须有一个注册表中CLSID项下指定的AppID值,以及相应的AppID项。 (已选中
  2. 在激活调用中,CLSCTX_LOCAL_SERVER 位已设置,并且 CLSID 键未指定 LocalServer32、LocalServer 或 LocalService。 (已选中
  3. CLSID 项包含 InprocServer32 子项。 (已检查
  4. InprocServer32 项中指定的代理/存根 DLL 存在。 ???
  5. DllSurrogate 值存在于 AppID 项下。 (已检查

Follow the check list:

  1. There must be an AppID value specified under the CLSID key in the registry, and a corresponding AppID key. (checked)
  2. In an activation call, the CLSCTX_LOCAL_SERVER bit is set and the CLSID key does not specify LocalServer32, LocalServer, or LocalService. (checked)
  3. The CLSID key contains the InprocServer32 subkey. (checked)
  4. The proxy/stub DLL specified in the InprocServer32 key exists. ???
  5. The DllSurrogate value exists under the AppID key. (checked)
仅一夜美梦 2024-08-17 03:52:39

错误的注册表项。您需要在 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.

沧笙踏歌 2024-08-17 03:52:39

这不就是 DLLHOST.EXE 的用途吗?

Isn't this what DLLHOST.EXE was made for?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文