[System.Runtime.InteropServices.DllImport("CH375DLL.dll")] static extern long CH375OpenDevice(long iIndex);
[System.Runtime.InteropServices.DllImport("CH375DLL.dll")] static extern Boolean CH375WriteData(long iIndex, Object iBuffer,long ioLength); public struct COMMAND_PACKET { public byte mCommandCode; public byte mCommandCodeNot; public byte[] mParameter; }
---------
outvalues=CH375OpenDevice(iIndex); COMMAND_PACKET mDemoReq =new COMMAND_PACKET(); mDemoReq.mParameter = new byte[20]; mDemoReq.mCommandCode = 0xEF; mDemoReq.mCommandCodeNot = 0xEF; mDemoReq.mParameter[2] = 0xEF; mDemoReq.mParameter[1] = 0xEF; if (outvalues==-1) {
textBox1.Text="无法打开设备"; } else { textBox1.Text=outvalues.ToString(); } if(CH375WriteData(0,mDemoReq,7)) { t2.Text="成功!"; } else {
t2.Text="不成功!"; }
这一行出错
if(CH375WriteData(0,mDemoReq,7))