views:

166

answers:

2

Hi,

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 !

A: 

may have a look at http://sourceforge.net/projects/libusbdotnet/ (never used it by myself)

Baldi
+2  A: 

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.

Cosmin Prund
That 's a good idea! I can list all network adapters on computer and disable one of them via WMI. However, how to make sure a adapter is a wifi or not?
Shinichi