怎么在vs2010中用c#调用c++的.dll文件

如题所述

添加namespace
using System.Runtime.InteropServices;
在调用dll的类里面添加
[DllImport("dll文件名", EntryPoint = "接口函数名", CallingConvention = CallingConvention.StdCall)]
public static extern 接口函数返回值 接口函数名(接口函数参数);
如:
[DllImport("mydll.dll", EntryPoint = "WriteInfo", CallingConvention = CallingConvention.StdCall)]
public static extern int WriteInfo(string PLCIp, int nPort, int ip, int dmAddress, int value);
dll文件需要放在你程序目录下
温馨提示:内容为网友见解,仅供参考
第1个回答  2016-08-18
看头文件 。。。。。。。。。。。
相似回答