C# 利用P/Invoke调用PMAC的Pcomm32.dll, 函数字符串返回值为空
大家帮我看看,这是利用P/Invoke委托连接PComm32.dll动态连接库,向一个PMAC设备发送指令的语句,向下发送能够成功,但返回值应该在buf值,但就是没有怎么回事?字符串buf为空,急等调试,谢谢各位高手,在线等
PMAC的PComm32.dll中函数原形为:long PMACGETRESPONSEA(DWORD dwDevice,PCHAR response,UINT maxchar,PCHAR command)
C#代码如下
namespace aaa
{
public delegate Int32 Delegate_GetResponsePmac(UInt32 dwDevice, string response, UInt32 maxchar, string command);//20080713
public class bbb: Form
{
dld test1 = new dld();
Delegate_GetResponsePmac GetResponsePmac;
private bbb_load
{
test1.LoadDll("PComm32.dll");
IntPtr GetResponsePmacAddress = test1.LoadFun("PmacGetResponseA");
GetResponsePmac = Marshal.GetDelegateForFunctionPointer(GetResponsePmacAddress, typeof(Delegate_GetResponsePmac)) as
}
private void button_click(object sender, EventArgs e)
{
string buf = "";
Int32 temp = GetResponsePmac(0, buf, 10, comboBox_Command.Text.ToString());
}
}
}