简体   繁体   English

如何通过C#检测USB Wifi插入计算机?

[英]How to detect USB Wifi plug into computer via C#?

I want to write a simple program that detect USB Wifi plugged computer and unplug it. 我想编写一个简单的程序来检测USB Wifi插入的计算机并将其拔出。 I am finding code or library help me to do that (C# or Delphi). 我发现代码或库可以帮助我做到这一点(C#或Delphi)。 Tell me if you know :) 告诉我你是否知道:)

Or 要么

Code or lib that list all USB devices on computer ? 列出计算机上所有USB设备的代码或库?

Thanks ! 谢谢 !

I can only answer part of the question. 我只能回答部分问题。 You can "eject" USB devices using this API: 您可以使用以下API“弹出” USB设备:

CM_Request_Device_Eject (MSDN link) CM_Request_Device_Eject(MSDN链接)

I'm using it to eject USB thumb drives after I copy stuff onto them in a backup application. 我在备份应用程序中将东西复制到USB拇指驱动器后,用它弹出USB拇指驱动器。 I'm pretty sure there are ways of enumerating available USB devices using one of the many CM_XXX routines, but I was only interested in storage devices connected via USB, so I can't comment on WiFi devices. 我很确定可以使用许多CM_XXX例程之一来枚举可用的USB设备,但是我只对通过USB连接的存储设备感兴趣,因此我无法对WiFi设备发表评论。

An other sugestion: Maybe you can solve your problem at an other layer, maybe you can detect the addition of a new network adapter and disable that. 另一个建议:也许您可以在另一层上解决问题,也许您可​​以检测到新的网络适配器的添加并将其禁用。 Not all USB devices can be ejected, it's probably a driver-related issue. 并非所有USB设备都可以弹出,这可能是与驱动程序相关的问题。 But I guess, if you can eject it from the notification area icon, you can eject it from code. 但是我想,如果您可以从通知区域图标中将其弹出,则可以从代码中将其弹出。

可以看看http://sourceforge.net/projects/libusbdotnet/ (我自己从未使用过)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM