作者iamso1 (可爱活泼小兽儿)
看板C_Sharp
标题[问题] C#中引入C++的dll档
时间Tue Aug 25 19:10:18 2009
我上网查了一下有关如何引用Dll档的文章
知道了要使用dllimport这方法
就是
[DllImport("我要引入的dll档")]
然後
public static extern ReturnType FunctionName(type arg1,type arg2,...);
但是 我发现上面那行中的"ReturnType" 好像都不是固定的
请问这里要看哪里判断呢?
接着是FunctionName的部分
我c++的dll中 程式码是
extern "C" __declspec(dllexport) int __stdcall CommOpen(int index, int
com_port);
extern "C" __declspec(dllexport) int __stdcall CommOpenS(int index, char
*com_name);
extern "C" __declspec(dllexport) int __stdcall CommClose(int index);
..
..
..
..
..
..
以下略
请问 我函式名称应该从哪里开始用呢??
是public static extern 然後接int __stdcall CommOpen(int index, int
com_port);
还是前面的extern "C" _declspec(dllexport)也要?
或是其他方式呢@@a
想请版友们帮忙解答一下 感恩
--
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.128.142.113
※ 编辑: iamso1 来自: 140.128.142.113 (08/25 19:10)
1F:推 leicheong:return type就是int啊... :O 08/25 20:07
2F:→ leicheong:public static extern int CommOpen(int index, 08/25 20:11
3F:→ leicheong:int com_port); 08/25 20:11
4F:→ iamso1:对不起 我突然有种恍然大悟的感觉XD 08/25 23:56
5F:→ iamso1:extern "C" __declspec(dllexport) int __stdcall 08/25 23:57
6F:→ iamso1:那上面那串 是要转成dll档才需要用到吗?? 08/25 23:57
7F:推 leicheong:那些都只是指定calling convension吧. P/Invoke会自己 08/27 22:00
8F:→ leicheong:处理... :P 08/27 22:00