ShareMem/ 与 Delphi DLL 进行字符串交换

发布于 2024-08-15 06:00:35 字数 416 浏览 5 评论 0原文

我希望快点 - 我即将深入研究一个 Delphi 5 遗留应用程序,该应用程序调用 DLL(也是用 D5 编写的),传递一个 DLL 可以根据需要修改的字符串。

我有 DLL 和应用程序的代码。粘贴在 DLL 源代码顶部的是关于使用 ShareMem 的注释,它需要成为项目的使用子句中的第一行等。

如果我将整个事情移植到 D2007,是否有更好的(或更多)现代)让 Delphi 应用程序与 Delphi DLL 共享字符串数据的方法? D5 ShareMem 内容是否仍然适用于 Delphi 2007 应用程序(使用 FastMM 等)?我什至还没有重新编译整个东西——只是想知道这是否会成为一个问题,是否有替代/推荐的方法来做到这一点?

FWIW,该 DLL 完全是第一方的(它仅由这个特定的应用程序使用 - 因此在 D2007 下重新编译它也不会成为问题)。

Quick one I hope - I'm just about to delve into a Delphi 5 legacy app that makes calls to a DLL (also written in D5), passing a string which the DLL can modify if required.

I have the code to both the DLL and the app. Pasted right at the top of the DLL source is a remark about using ShareMem, and it needing to be the first line in the uses clause of the project etc.

If I was porting this whole thing to D2007, is there a better (or more modern) way of getting a Delphi app to share string data with a Delphi DLL? Does the D5 ShareMem stuff still apply to Delphi 2007 applications (with FastMM etc)? I haven't even had a bash at recompiling the whole thing yet - just wondered if this bit was going to be a problem and if there was an alternative/recommended way of doing this?

FWIW, the DLL is totally first party (it's only used by this particular app - so recompiling it under D2007 as well wouldn't be a problem).

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

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

发布评论

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

评论(3

碍人泪离人颜 2024-08-22 06:00:35

要使用 D2007 中包含的 FastMM,请使用 SimpleShareMem 作为应用程序和 DLL 项目中的第一个单元。

或者从 SourceForge 下载完整的 FastMM4,在 FastMM4Options.Inc(ShareMM、ShareMMIfLibrary、AttemptToUseSharedMM)中设置标志,并将 FastMM4 作为应用程序和 DLL 项目中的第一个单元。

To use the FastMM included with D2007, use SimpleShareMem as the 1st unit in both your application and the DLL projects.

Or download the full FastMM4 from SourceForge, set the Flags in FastMM4Options.Inc (ShareMM, ShareMMIfLibrary, AttemptToUseSharedMM) and put FastMM4 as the 1st unit in both the application and the DLL projects.

偏闹i 2024-08-22 06:00:35

仅使用 FastMM4。 FastMM4 是一个出色的内存管理器,并自动包含类似 ShareMem 的解决方案! FastMM4 与 D5 及更高版本兼容!

Use only a FastMM4. FastMM4 is a great memory manager and automatically includes a ShareMem like solution! FastMM4 is compatible with D5 and up!

哥,最终变帅啦 2024-08-22 06:00:35

您需要 sharemem 的原因是,ansiststrings 上的引用计数在传递给 dll 时会中断。一种解决方案是:-

如果您能够将字符串限制为短字符串,那么您可以省去 sharemem。我已经编写了大约两打 dll,主要是硬件驱动程序,而且我一次也没有使用过 sharemem。

The reason you need sharemem is that the reference counting on ansistrings breaks when passed to a dll. One solution is :-

If you are able to restrict your strings to shortstring then you can dispense with sharemem. I have written some two dozen dlls, mostly drivers for hardware and I have not had to use sharemem once.

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