![]() |
#2
小xiong2013-04-14 23:01
|
// kkk.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <windows.h>
#include <afxwin.h>
#include <afx.h>
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hcom=CreateFile("COM7",GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL|FILE_FLAG_OVERLAPPED,NULL);
if(hcom==INVALID_HANDLE_VALUE)
{
AfxMessageBox("打开com失败");
int err=GetLastError();
CString st;
st.Foormat("Error in open COM port:%d\n",err);
}
MessageBox(st);
return ;
}