Y
yousun123
Unregistered / Unconfirmed
GUEST, unregistred user!
begin
OpenComm;
btnOpenPort.caption:='关闭通信端口';
end
procedure TForm1.OpenComm;
var
cc:TCOMMCONFIG;
Temp:string;
begin
Temp:='COM'+inttostr(rdcom.ItemIndex+1);
//选择所要打开的通信端口
hComm:=CreateFile(PChar(Temp),GENERIC_READ or GENERIC_WRITE,
0,nil,OPEN_EXISTING, 0, 0);
//打开通信端口
if (hComm = INVALID_HANDLE_VALUE) then
begin
//如果通信端口未打开
btnOpenPort.caption:='打开通信端口';
MessageBox (0,'无法打开通信端口!','',MB_OK);
exit;
end;
end;
当无法打开通信端口时如何让btnOpenPort.caption:='打开通信端口';
而不是btnOpenPort.caption:='关闭通信端口';
OpenComm;
btnOpenPort.caption:='关闭通信端口';
end
procedure TForm1.OpenComm;
var
cc:TCOMMCONFIG;
Temp:string;
begin
Temp:='COM'+inttostr(rdcom.ItemIndex+1);
//选择所要打开的通信端口
hComm:=CreateFile(PChar(Temp),GENERIC_READ or GENERIC_WRITE,
0,nil,OPEN_EXISTING, 0, 0);
//打开通信端口
if (hComm = INVALID_HANDLE_VALUE) then
begin
//如果通信端口未打开
btnOpenPort.caption:='打开通信端口';
MessageBox (0,'无法打开通信端口!','',MB_OK);
exit;
end;
end;
当无法打开通信端口时如何让btnOpenPort.caption:='打开通信端口';
而不是btnOpenPort.caption:='关闭通信端口';