从 DLL 发送数组 - VC++
我用VC++写了一个dll。我想问一下dll中的方法是否可以返回数组?
返回的数组是否与使用 DLL 的任何语言兼容? As-In 兼容 C#、Java...等。
如果我能找到一些线索,我会很高兴。
谢谢。
I have written a dll in VC++. I wanted to ask if it is possible for a method in a dll to return an array?
And would that array returned, be compatible with any language that is using the DLL? As-In compatible with C#, Java...etc.
I would be glad if I could get some leads in to it.
thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这绝对有可能。
从内存分配的角度来看,最简单的方法是让调用者传递两个参数 - 一个用于写入数组的缓冲区和一个指示缓冲区大小的整数。这样,您就不必担心在 DLL 和调用方中使用相同的分配器来分配和释放内存。
Yes, that's absolutely possible.
The easiest approach from a memory allocation point of view is to let the caller pass in two parameters - a buffer where you write the array to and an integer indicating the size of the buffer. That way you don't have to worry about using the same allocator in the DLL and in the caller to allocate and free the memory.