18,356
社区成员
发帖
与我相关
我的任务
分享
void CPLCconnectDlg::OnBnClickedConnect()
{
CString strIP(L"192.168.2.15");
if(!PLC_1.Create())
{
AfxMessageBox(L"创建失败!");
return;
}
if(PLC_1.Connect(strIP, 1234))
{
AfxMessageBox(L"连接成功!");
pTread = AfxBeginThread(ThreadFunc, &Info);
}
}
BOOL g_bCreated = FALSE; // 全局变量
void CPLCconnectDlg::OnBnClickedConnect()
{
CString strIP(L"192.168.2.15");
if(!g_bCreated)
{
if(!PLC_1.Create())
{
AfxMessageBox(L"创建失败!");
return;
}
g_bCreated = TRUE;
}
//if(PLC_1.Connect(strIP, 1234))
//{
// AfxMessageBox(L"连接成功!");
// pTread = AfxBeginThread(ThreadFunc, &Info);
//}
}