作者dm33 ()
看板C_Sharp
标题Re: [问题] c++里的指标函数到C#怎麽处理??
时间Fri Jul 20 18:02:58 2007
自回了
我是不知道怎麽在dllimport时怎麽宣告...
网路上找了老半天,又跑去查msdn,有看到是用delegate
是先宣告一个
delegate int mydelegate(string str);
[System.Runtime.InteropServices.DllImport("DLL.dll")]
public extern static int _DLL_StatusFunc(mydelegate t);
其实昨天有想到这样做,不过昨天怎麽没写出来,鬼挡墙了...
※ 引述《dm33 ()》之铭言:
: 因为有用到dll,原本此dll是用c++来使用的,所以用到不少指标的东西
: 一般的function是可以使用,就是参数是指标函数的,就不知道怎麽在
: C#里处理了。
: 如
: int _DLL_StatusFunc (int (*statusfunc) (char *));
: c++里是直接
: extern "C" __declspec (dllimport) _DLL_StatusFunc (int (*func) (char *));
: 使用的时候 就放函数就行了
: 而C#就不知道怎麽改了~~有大大能帮忙解答一下吗 感谢!!
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.115.126.238