听取串口知道C#中是否安装了调制解调器。 [英] listening to serial port to know whether modem installed/removed in C#.

查看:85
本文介绍了听取串口知道C#中是否安装了调制解调器。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何连续收听COM以检测调制解调器。

如果添加或删除调制解调器,它应通知您在COM45等安装或删除调制解调器等



我试过使用一个线程并检查计数,但我无法知道哪个com是调制解调器。



如果有这个任何特定的类帮助我解决代码asap ???

How will i continuous listen to COM for detecting modem.
if a modem is added or removed it should inform you that Modem installed or removed at COM45 etc.

I have tried to use a thread and check the com count but i am unable to know which com is modem.

If there is any specific class for this pls help me fr the code asap???

推荐答案

实现这一目标的方法之一是打开com端口,如



one of the way to achieve this is open the com port like

SerialPort com = new SerialPort("com1");
com.Open();





你可以从i循环到250 com端口如果不成功会抛出异常

并且你可以处理它。

否则它将成功打开端口



your can loop from i to 250 com port if unsuccessful it will throw exception
and you can handle it.
other wise it will successfully open the port


这篇关于听取串口知道C#中是否安装了调制解调器。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆