C#调用C++的DLL时,如果函数的参数有指针类型,该如何写声明

如题所述

第1个回答  2012-03-31
所有的指针均可以用IntPtr来转换。追问

请问,应该如何进行转换呢?有例子么?网上搜过,看不懂

追答

比如说C++的test.dll中的一个函数为
long TestMethod(long a, char* b, int *c);
调用过程如下:
[DllImport("test.dll")]
public static extern int TestMethod( int a, string b,IntPtr c);
你可以百度一下C++和C#数据类型对应关系。

本回答被提问者采纳
第2个回答  2012-03-30
我也想知道,做个记号!
相似回答