开发者

How can I pass a Delphi array of integers to a Prism DLL?

I've read a开发者_JAVA百科nd 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.


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


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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜