WriteFile() 的问题,急急,在线等!!!!

songxinSQL 2009-05-30 10:48:52

void CSerialInterface::SerialComSend(BYTE lpOutBuffer[])
{
OVERLAPPED m_Write;
memset(&m_Write,0,sizeof(OVERLAPPED));

DWORD dwBytesWrite=8;
COMSTAT ComStat;
DWORD dwError;
BOOL bWriteStat;
ClearCommError(hCom,&dwError,&ComStat);

bWriteStat=WriteFile(hCom,lpOutBuffer,dwBytesWrite,&dwBytesWrite,&m_Write);
if(bWriteStat==0)
{
long int iError=GetLastError();
}
}


void CMyDlg::OnButtonUp()
{
// TODO: Add your control notification handler code here
BYTE upcommand[8]={0xa0,0x01,0x00,0x08,0x00,0x30,0xaf,0x39};

m_vidiconCom.SerialComSend(upcommand);
}


我在OnButtonUp()调用的时候我用GetLastError()返回值是997,那么WriteFile()是什么问题那?高手帮忙解答下,急急!!!
...全文
113 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
僵哥 2009-05-30
  • 打赏
  • 举报
回复
...
m_Write.hEvent = CreateEvent(NULL, true, true, NULL);bWriteStat=WriteFile(hCom,lpOutBuffer,dwBytesWrite,&dwBytesWrite,&m_Write);
if(bWriteStat==0)
{
long int iError=GetLastError();
if(iError != ERROR_IO_PENDING /*997*/) {
CloseHandle(m_Write.hEvent);
return;
}


}
GetOverlappedResult(hCom, &m_Write, &dwBytesWrite, true);
CloseHandle(m_Write.hEvent);

}
hackwolfoscar 2009-05-30
  • 打赏
  • 举报
回复
重叠 I/O 操作在进行中。


需要等待完成
yanjing_mail 2009-05-30
  • 打赏
  • 举报
回复
重叠 I/O 操作在进行中。

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧