怎样检查串口是否被占用!!
rrqx 2002-04-19 02:05:14 我想检查串口是否被占用,使用了
Mscomm.portopen 是否为 TURE 来判断,但无效
当 串口 被程序调用 时,它不会自己跳越 到 下一串口; 如果串口不存在它也检测不到,附程序,在线等答案!!
'计算机上串口假定最多四个
MSCommSt.CommPort = 1
If MSCommSt.PortOpen Then
MSCommSt.CommPort = 2
If MSCommSt.PortOpen Then
MSCommSt.CommPort = 3
If MSCommSt.PortOpen Then
MSCommSt.CommPort = 4
If MSCommSt.PortOpen Then
MsgBox "串口1到4都被占用!检查,空出一串口,再运行本程序!", , "警告!"
Exit Sub
End If
End If
End If
End If
MSCommSt.PortOpen = True