如何将 Delphi 整数数组传递给 Prism DLL?

发布于 2024-09-18 09:30:28 字数 204 浏览 11 评论 0原文

我已阅读并成功尝试了 的答案如何将 Delphi 字符串传递给 Prism DLL?,但想知道是否可以使用类似的方法将 Delphi 整数数组(静态或动态)传递给 Prism DLL。

I've read and successfully tried the answer to How can I pass a Delphi string to a Prism DLL?, but wondered if it was possible to use a similar method to pass a Delphi array of integers (static or dynamic) to a Prism DLL.

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

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

发布评论

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

评论(2

孤独陪着我 2024-09-25 09:30:28

最简单的(无需编组)是使用 BASE16 或 BASE64 将数组编码为 un​​icode 字符串并传递一个字符串。

The simpliest (without marshalling) is to encode the array using BASE16 or BASE64 into a unicode string and pass a string.

隔岸观火 2024-09-25 09:30:28

我没有时间编写完整的工作示例,但以下是适应您在另一个问题中提到的示例的关键事项:

使用缓冲区长度声明类型

type
  [MarshalAs(UnmanagedType.LPArray)]
  TBuffer = array[0..-length-]of integer;

并在缓冲区中进行操作记住使用“固定”修改器

var BufferPointer: ^TBuffer; pinned;

...

  BufferPointer := @the_buffer[0];

I don't have time to write a full working example but here are the key things to adapt the example you mention in the other question:

declare a type with your buffer length

type
  [MarshalAs(UnmanagedType.LPArray)]
  TBuffer = array[0..-length-]of integer;

and to make operations in the buffer remember to use the "pinned" modifier

var BufferPointer: ^TBuffer; pinned;

...

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