第一次用 VC 不熟悉 调试下面程序有问题 望能指教void CCommonDlg::Onpara() // 读24c16 里的网络参数;
{
OVERLAPPED osWrite = {0};
DWORD dwWritten;
DWORD dwRes;
//OVERLAPPED osReader = {0};
DWORD dwRead;
int b[18];
int a[18];
a[0]=0x3e;
a[1]=0x04;
osWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (osWrite.hEvent == NULL) return;
WriteFile(hComm, a, 18, &dwWritten, &osWrite);
int aaa=GetLastError(); // aaa 错误代号为 997为何 WriteFile 函数写不进?
{
OVERLAPPED osWrite = {0};
DWORD dwWritten;
DWORD dwRes;
//OVERLAPPED osReader = {0};
DWORD dwRead;
int b[18];
int a[18];
a[0]=0x3e;
a[1]=0x04;
osWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (osWrite.hEvent == NULL) return;
WriteFile(hComm, a, 18, &dwWritten, &osWrite);
int aaa=GetLastError(); // aaa 错误代号为 997为何 WriteFile 函数写不进?
解决方案 »
- vc调用activex 控件REALPLAYER G2 CONTROL,可以编译通过,但是程序无法运行
- 为什么我这个代码不能把图片拷贝到我的打印DC上呢,请大家帮忙看看,谢谢了
- 关于cvCopy拼接图像的问题
- 求助:下一步我该学什么
- p2p, 如果没有一个自己的中间服务器,如何实现?
- DX问题。用BltFast绘图若图象超出DDS范围会失败,如何解决?
- 关于用UDP通讯的问题,
- 菜鸟请高手指教一个关于动态存放字符变量和浮点变量的问题
- 编写exe类型的ATL 是否可以使用mfc类
- 我有一组combo,ID从0-4,我想用一个函数处理所有combo的SelChange事件,怎样设置事件处理?
- 初学MFC用什么书啊??大家推荐一下吧
- 不想囫囵糊涂学COM,想知道COM的本质之COM内存结构
if (aaa == ERROR_IO_PENDING)
if ( GetOverlappedResult(hComm, &osWrite, &dwWritten, TRUE) )
// OK
else
// Error
{
// TODO: Add your control notification handler code here
OVERLAPPED osWrite = {0};
DWORD dwWritten;
DWORD dwRes;
//OVERLAPPED osReader = {0};
DWORD dwRead;
int b[18];
int a[18];
a[0]=0x3e;
a[1]=0x04;
osWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (osWrite.hEvent == NULL) return;
WriteFile(hComm, a, 18, &dwWritten, &osWrite);
if ( GetOverlappedResult(hComm, &osWrite, &dwWritten, TRUE) )
{
123 AfxMessageBox ("ok"); //这里显示成功了 就是说发下去的
// 命令成功 即 0x3E 0x04
}// OK
else
{
AfxMessageBox ("error");
}
这个函数ReadFile(hComm, b, 18, &dwRead, &osReader);
既 收 24c16里的 参数 这么写对不? 放 123 处么?
见笑啦 第一次用VC
}
if ( !bRet ) {
iError = GetLastError();
if ( iError == ERROR_IO_PENDING ) {
bRet = GetOverlappedResult(hComm, &osWrite, &dwWritten, TRUE);
}
}if ( bRet ) { // 发送成功
COMSTAT stComStat;
DWORD dwErrorFlag;
ClearCommError(hComm, &dwErrorFlag, &stComStat);
if ( stComStat.cbInQue > 0 ) { // 串口有数据
bRet = ReadFile(hComm, b, 18, &dwRead, &osReader);
if ( bRet ) {
bRet = GetOverlappedResult(hComm, &osReader, &dwRead, FALSE);
}
}
}