将回调函数中的指针从c / c ++传递给c# [英] passing pointers in callback functions from c/c++ to c#
本文介绍了将回调函数中的指针从c / c ++传递给c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找将指向c / c ++的字节数组的指针传递给c#的示例代码。谢谢
I am looking for example code on passing a pointer to byte array from c/c++ to c#. thanks
推荐答案
尝试使用 Marshal.Copy方法(IntPtr,Byte [],Int32,Int32) [ ^ ]
我正在寻找c / c ++回调API和c#API。以下对我来说似乎不起作用。
在本机C / C ++代码API中定义如下:
int callback(int t ,char * data)
在托管C#API中定义如下:
委托int回调(int t,IntPtr数据)
如果从回调中删除了数据参数,它就有效。
I am looking for the c/c++ callback API and c# API. The following does not seem work for me.
In native C/C++ code API is defined as follow:
int callback (int t, char *data)
In managed C# API is defined as follow:
delegate int callback (int t, IntPtr data)
It works if the data parameter is removed from the callback.
这篇关于将回调函数中的指针从c / c ++传递给c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文