如何在D中导入COM dll

发布于 2024-12-16 17:19:19 字数 542 浏览 0 评论 0 原文

我正在尝试创建一个使用(第三方)COM .dll 的 D 应用程序,这样我就可以抓取另一个应用程序的文本框,这样当某个字符串出现时我就可以发出错误消息。

然而,第三方不提供与 dll 一起使用的 .lib、.def 或 .h 文件(至少在免费试用版中)。我可以使用 implib 工具创建 .lib 文件,但我没有看到任何创建的 .lib 中的库函数。

他们的(Visual C++)示例使用 #import 指令来链接它,但这对我来说没有用......

顺便说一下,我怎样才能获得正确的接口(在 .di 中)自动链接 dll 的样板?我问,链接的正确性并不取决于我对函数的翻译(可能不正确)。他们确实有一个网页,它提供了所有功能,但对象模型有点混乱至少可以说。

I'm trying to create an D application which uses a (third party) COM .dll so I can scrape a text box of another application so I can sound an error when a certain string shows up.

However the third party doesn't provide .lib, .def or .h files that go with the dll (atleast with the free trial version). I can create the .lib file with the implib tool but I don't see any of the library's functions in the created .lib.

Their (visual c++) samples use the #import directive to link it in however that is of no use for me ...

On a side note how can I get the proper interfaces (in a .di with boilerplate that does the linking) of the dll automatically? I ask so the correctness of the linkage doesn't depend on my (likely to be incorrect) translation of the functions. They do have a webpage which gives all functions but the object model is a bit chaotic to say the least.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

鯉魚旗 2024-12-23 17:19:19

据我所知,COM 库仅公开一些函数,这些函数是注册(注销)库和创建对象所需的。
但是,您可以使用 OLE/COM 对象查看器。看来它可能能够输出头文件(.h)。之后,也许您可​​以使用 htod 作为将所有内容转换为 D 接口的起点。

DMD 发行版似乎包含一个 .COM 示例(chello.d、dclient.d、dserver.d),乍一看它似乎不需要任何明确的 LIB。

不幸的是,我从未在 D 中实际使用过 COM,所以我无法提供更多建议。我希望这能在某种程度上有所帮助。

From what I know, COM libraries only expose a few functions, required to (un)register the library and to create objects.
You can however view the interfaces and functions in a COM .dll using the OLE/COM Object Viewer. It seems it might be able to output header files (.h). Afterwards, maybe you could use htod as a starting point to converting everything to D interfaces.

The DMD distribution seems to include a .COM sample (chello.d, dclient.d, dserver.d), and at first glance it doesn't look like it would require any LIBs explicitly.

Unfortunately, I've never actually used COM in D, so I can't advise any further. I hope this helps in some way.

虫児飞 2024-12-23 17:19:19

虽然我自己还没有实际进行 COM 工作,但我正在尝试在 Juno “https://github.com/he-the-great/Juno-Windows-Class-Library”rel="nofollow">Github/he-the-great。该项目的一部分是 tlbimpd ,它将从 DLL 输出 D 文件。

我已经测试了这些示例并成功运行了 tlbimpd。请尝试使用并提交任何问题。

While I have yet to actually do COM work myself, I am trying to revive Juno over on Github/he-the-great. Part of the project is tlbimpd which is what will output a D file from a DLL.

I've tested the examples and successfully run tlbimpd. Please do try things out for your use and submit any issues.

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