我们可以通过C#检测USB端口连接的设备类型吗? [英] Can we detect device type connected in USB port through C#?
问题描述
在C#中,我们可以编写一个程序来执行以下操作吗?
每当通过USB端口连接某个外部设备时:
iI可以检测设备类型[网络摄像头,读卡器等]
ii。搜索本地m / c中是否存在相应的驱动程序s / w,如果找到,执行自动[运行]。
还有其他功能主义者,但首先,我们可以实现上述两种情况吗?
谢谢,
Avishek
我会从 here [ ^ ](或许多其他 [ ^ ] Google上的资源。)
添加到Manas的答案:
你很可能需要P / InvokeRegisterDeviceNotification
和相关的API。
见 http://msdn.microsoft.com/en-us/library/aa363431 (v = vs.85).aspx [ ^ ]
绝对亲爱的,
使用system.io;
//使用
获取所有驱动器枚举DriveInfo di [] = DriveInfo.GetDrives();
foreach(FI中的DriveInfo divinfo)
{
If(divinfo.IsReady)
{
Console.writeline(divinfo.DriveType);
}
其他
Console.Writeline(设备未就绪);
}//自动检测设备
使用定时器控件并在每5或10秒钟调用一个包含此for循环的方法
Hi,
In C#, can we write a program which will do the following thing?
Whenever some external device is connected with it through USB port:
i.I can detect the device type[webcam,card reader etc.]
ii.Search the existence of corresponding driver s/w in the local m/c,if found,execute[run] automatically.
There are other additional functionalists as well,but for the beginning,can we implement the above two scenarios?
Thanks,
Avishek
I would start reading up from here[^] (or many other[^] resources on Google).
Adding to Manas''s answer:
You will most likely need to P/InvokeRegisterDeviceNotification
and related APIs.
See http://msdn.microsoft.com/en-us/library/aa363431(v=vs.85).aspx[^]
absolutely dear,
using system.io; //Get all drives enumeration using DriveInfo di[]= DriveInfo.GetDrives(); foreach(DriveInfo divinfo in fi) { If(divinfo.IsReady) { Console.writeline(divinfo.DriveType); } else Console.Writeline("Device not Ready"); }// To detect devices automatically
use a timer control and call a method in every 5 or 10 second that include this for loop
这篇关于我们可以通过C#检测USB端口连接的设备类型吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!