110,566
社区成员
发帖
与我相关
我的任务
分享
void CTEST_PORT_DLLDlg::OnOK()
{
// TODO: Add extra validation here
Init(2,9600); //初始化串口
SetReceiveFuntion(&ReveveChar);//指定接收和处理数据的函数
//CDialog::OnOK();
}
void ReveveChar(WPARAM data, LPARAM port)//实现接收和处理数据的函数
{
static int RecevCount = 0;
char str[512] = "";
sprintf(str,"%02x",data);
strTemp += str;
RecevCount++;
if (RecevCount >= 8)
{
RecevCount = 0;
strTemp = "接收到得数据协议为:" + strTemp;
AfxGetMainWnd()->GetDlgItem(IDC_EDITRECEV)->SetWindowText(strTemp);
//AfxMessageBox(strTemp);
strTemp = "";
}
}
1 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
C#里面只要被回调一次,程序就异常退出。返回值:0x80000003。如下:
程序“[24768] YKYDemo.vshost.exe: 托管(v4.0.30319)”已退出,返回值为 -2147483645 (0x80000003)。[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
包含在:
using System.Runtime.InteropServices;
太不容易了。。。
具体会不会影响C++Dll的稳定性,还要多试验。。。