Wince下面的串口通讯控件
请问EVC4.0下面有没有类似VC6里面的MSComm控件,或者可不可以使用MSComm啊,怎么使用啊。请大家帮帮忙哦,谢谢了! 问题点数:100、回复次数:13Top
1 楼supercc(帅帅)回复于 2005-02-17 10:32:05 得分 10
据我所知没有,得用api来写
mscomm控件不能在wince里面用Top
2 楼poni(poni)回复于 2005-02-17 11:02:03 得分 0
同意楼上的,用API吧,很简单的Top
3 楼zhangjerry(吉吉)回复于 2005-02-17 11:58:50 得分 0
请问API应该怎么写啊,其实我现在的问题就是我应该用什么控件来显示我接收到的串口的消息。谢谢,就像很多PC端串口通讯软件里面的那个显示接收信息的控件,可以把不能在一行显示完全的信息分行显示,谢谢!Top
4 楼taotao7805(韬滔)回复于 2005-02-17 15:58:10 得分 10
网上很多这样的串口通信程序,一搜就能找到,找不到我给你一个。Top
5 楼zhangjerry(吉吉)回复于 2005-02-17 16:33:33 得分 0
谢谢,我找到的都是VC下的,能不能帮我找一个wince下面的串口程序,谢谢了!Top
6 楼supercc(帅帅)回复于 2005-02-18 09:17:07 得分 0
楼主用什么工具啊
我有delphi和c#的Top
7 楼poni(poni)回复于 2005-02-18 09:33:59 得分 10
其实和VC的差不多,只是改一下引用的动态库Top
8 楼poni(poni)回复于 2005-02-18 09:44:14 得分 40
//Open the serial port.
hPort = CreateFile ( _T("COM1:"),
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if ( hPort == INVALID_HANDLE_VALUE )
{
AfxMessageBox(_T(" open com port error !"));
return ;
}
else
AfxMessageBox(_T(" open com port Ok !"));
DCB PortDCB;
GetCommState (hPort, &PortDCB); // Structure de configuration
PortDCB.DCBlength = sizeof (DCB);
PortDCB.BaudRate = 9600;
PortDCB.fBinary = TRUE;
PortDCB.fParity = TRUE;
PortDCB.fOutxCtsFlow = FALSE;
PortDCB.fOutxDsrFlow = FALSE;
PortDCB.fDtrControl = DTR_CONTROL_ENABLE;
PortDCB.fDsrSensitivity = FALSE;
PortDCB.fTXContinueOnXoff = TRUE;
PortDCB.fOutX = FALSE;
PortDCB.fInX = FALSE;
PortDCB.fErrorChar = FALSE;
PortDCB.fNull = FALSE;
PortDCB.fRtsControl = RTS_CONTROL_ENABLE;
PortDCB.fAbortOnError = FALSE;
PortDCB.ByteSize = 8;
PortDCB.Parity = NOPARITY;
PortDCB.StopBits = ONESTOPBIT;
if (!SetCommState (hPort, &PortDCB))
{
AfxMessageBox(_T(" Set com port error !"));
}
else
AfxMessageBox(_T(" Set com port Ok !"));
}
// 发送
DWORD dwNumBytesWritten;
BYTE Byte = 'a';
if (!WriteFile (hPort,
&Byte,
1,
&dwNumBytesWritten,
NULL))
AfxMessageBox(_T(" write error !"));
else
AfxMessageBox(_T(" write ok !"));
// 关闭
if(hPort!=INVALID_HANDLE_VALUE)
if(!CloseHandle(hPort))
AfxMessageBox(_T(" close error !"));
else
AfxMessageBox(_T(" close ok !"));
Top
9 楼91program(当时明月在,曾照彩云归)回复于 2005-02-18 13:20:25 得分 10
在EVB3中有MSCOMM控件,可以使用。但不能在EVC中使用!Top
10 楼poni(poni)回复于 2005-02-19 16:31:52 得分 0
顶上去Top
11 楼cczmm(星星)回复于 2005-02-22 21:22:09 得分 10
说简单,也不容易。要想真正搞清楚,还是需要一番功夫的,
毕竟和左面系统有明显的区别。
我就花了几个月。Top
12 楼dyh0(助人乃快乐之本!)回复于 2005-04-18 16:28:52 得分 0
markTop
13 楼jiess(刘伟庭)回复于 2005-04-18 18:25:46 得分 10
呵呵,用API吧,这样的例子很多吧,
你去网上找一个书<<wince 程式设计>>英文电子版,我在一些贴子上也贴过链接.里面有wince下的串口通讯实例Top




