27,375
社区成员
发帖
与我相关
我的任务
分享
char buffer[1024];
DWORD dwBytesWritten=1024;
DWORD dwErrorFlags;
COMSTAT ComStat;
OVERLAPPED m_osWrite;
BOOL bWriteStat;
bWriteStat = WriteFile(hCom,buffer, dwBytesWritten, &dwBytesWritten, &m_OsWrite);
if (!bWriteStat)
{
if(GetLastError()==ERROR_IO_PENDING)
{
WaitForSingleObject(m_osWrite.hEvent,1000);
return dwBytesWritten;
}
return 0;
}
return dwBytesWritten;
char buffer[1024];
DWORD dwBytesWritten=1024;
DWORD dwErrorFlags;
COMSTAT ComStat;
OVERLAPPED m_osWrite;
BOOL bWriteStat;
//初始化overlaooped结构!!
m_osWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
m_osWrite.Offset = 0;
m_osWrite.OffsetHigh = 0;
bWriteStat = WriteFile(hCom,buffer, dwBytesWritten, &dwBytesWritten, &m_OsWrite);
if (!bWriteStat)
{
if(GetLastError()==ERROR_IO_PENDING)
{
WaitForSingleObject(m_osWrite.hEvent,1000);
return dwBytesWritten;
}
return 0;
}
return dwBytesWritten;