Linux 如何将 Delphi 整数数组传递给 Prism DLL?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3677072/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I pass a Delphi array of integers to a Prism DLL?
提问by Warren Stanley
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.
我已阅读并成功尝试了如何将 Delphi 字符串传递给 Prism DLL?,但想知道是否可以使用类似的方法将 Delphi 整数数组(静态或动态)传递给 Prism DLL。
回答by Eugene Mayevski 'Callback
The simpliest (without marshalling) is to encode the array using BASE16 or BASE64 into a unicode string and pass a string.
最简单的(没有编组)是使用 BASE16 或 BASE64 将数组编码为 unicode 字符串并传递字符串。
回答by someone
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
并在缓冲区中进行操作记得使用“pinned”修饰符
var BufferPointer: ^TBuffer; pinned;
...
...
BufferPointer := @the_buffer[0];