添加
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文件需要放在你程序目录下