Subject:
关于TCnRS232的建议(其实是spcomm的问题)
[Print This Page]
Author:
toysun
Time:
2008-12-15 11:00
Subject:
关于TCnRS232的建议(其实是spcomm的问题)
其实是spcomm的问题
1.StartComm方法中
hNewCommFile := CreateFile(PChar(CommName), GENERIC_READ or GENERIC_WRITE,
0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED, 0);
修改为
hNewCommFile := CreateFile(PChar('\\.\' + CommName), GENERIC_READ or GENERIC_WRITE,
0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED, 0);
{解决串口号大于10无法识别的问题}
2.CommWndProc中加上默认消息处理
procedure TCnRS232.CommWndProc(var Msg: TMessage);
begin
case Msg.Msg of
PWM_GOTCOMMDATA:
begin
ReceiveData(PChar(Msg.LPARAM), Msg.WPARAM);
LocalFree(Msg.LPARAM)
end;
PWM_RECEIVEERROR: ReceiveError(Msg.LPARAM);
PWM_MODEMSTATECHANGE: ModemStateChange(Msg.LPARAM);
PWM_REQUESTHANGUP: RequestHangup;
PWM_SENDDATAEMPTY: _SendDataEmpty;
else
with msg do //默认消息处理,解决win98无法正常退出问题
//(WM_QUERYENDSESSION和WM_ENDSESSION)
Result := DefWindowProc(FHWnd, Msg, WParam, LParam);
end;
end;
Author:
Passion
Time:
2008-12-17 08:53
感谢楼主的报告。此建议已采纳,改动已并入最新的CVS代码。您可从CVS上获取最新代码来试一试。
Author:
Redbreast
Time:
2008-12-17 20:52
的确是一个老问题了,一直在打开串口的时候修改,呵呵,如果直接修改了,看来我还得修改我滴源码了:)
Welcome to CnPack Forum (http://bbs.cnpack.org/)
Powered by Discuz! 5.0.0