如何通过C#检测USB Wifi插入电脑?
我想编写一个简单的程序来检测 USB Wifi 插入的计算机并将其拔出。我正在寻找代码或库帮助我做到这一点(C# 或 Delphi)。如果您知道请告诉我:)
或者
列出计算机上所有 USB 设备的代码或库?
谢谢 !
I want to write a simple program that detect USB Wifi plugged computer and unplug it. I am finding code or library help me to do that (C# or Delphi). Tell me if you know :)
Or
Code or lib that list all USB devices on computer ?
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我只能回答部分问题。您可以使用此 API“弹出”USB 设备:
CM_Request_Device_Eject ( MSDN 链接)
我在备份应用程序中将内容复制到 USB 拇指驱动器上后,使用它弹出 USB 拇指驱动器。我很确定有一些方法可以使用众多 CM_XXX 例程之一枚举可用的 USB 设备,但我只对通过 USB 连接的存储设备感兴趣,所以我无法评论 WiFi 设备。
另一种建议:也许您可以在其他层解决您的问题,也许您可以检测到新网络适配器的添加并禁用它。并非所有 USB 设备都可以弹出,这可能是与驱动程序相关的问题。但我想,如果你可以从通知区域图标中弹出它,你就可以从代码中弹出它。
I can only answer part of the question. You can "eject" USB devices using this API:
CM_Request_Device_Eject (MSDN link)
I'm using it to eject USB thumb drives after I copy stuff onto them in a backup application. 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.
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. But I guess, if you can eject it from the notification area icon, you can eject it from code.
可以看看 http://sourceforge.net/projects/libusbdotnet/ (从未使用过我自己)
may have a look at http://sourceforge.net/projects/libusbdotnet/ (never used it by myself)