c#调用c++的dll
我现在在用c#调用一个c++写的DLLc++的范例是这样的
char ver[32] = "";
JBC7K2_Version(ver, ip, port)
ip是string类型
port是int类型
我在c#中调用怎么老出错
[DllImport("JBC7200A", EntryPoint = "JBC7K2_Version", CharSet = CharSet.Auto)]
public static extern int JBC7K2_Version(ref char[] ver, string ip, int port);
protected void Button3_Click(object sender, EventArgs e)
{
char[] ver = getbyte1(32);
try
{
JBC7K2DLL.JBC7K2_OpenSocket();
int i = JBC7K2DLL.JBC7K2_Version(ref ver, "172.16.1.233", 5101);
this.TextBox5.Text = i.ToString().Trim();
}
finally
{
JBC7K2DLL.JBC7K2_CloseSocket();
}
}
在綫等 谢谢各位大佬 --------------------编程问答-------------------- --------------------编程问答-------------------- 试下:
[DllImport("JBC7200A", EntryPoint = "JBC7K2_Version", CharSet = CharSet.Auto)]
public static extern int JBC7K2_Version(StringBuilder ver, string ip, int port);
--------------------编程问答-------------------- lz,你把JBC7K2_Version这个函数C++定义原型贴出来,同时把错误信息一起贴出来。。。。
--------------------编程问答-------------------- sd 我沒有原型函数 ,dll是一个公司给提供的 它只给了一个代码示例 --------------------编程问答-------------------- 谢谢js 我搞定了
补充:.NET技术 , .NET Framework