I try to get all usb devices (including portable devices) in Windows 7 now I searched everything and did not find a good answer.
I tried this code:
static void Main(string[] args)
{
PortableDeviceApiLib.PortableDeviceManagerClass devMgr
= new PortableDeviceApiLib.PortableDeviceManagerClass();
uint cDevices = 1;
devMgr.GetDevices(null, ref cDevices);
if (cDevices > 0)
{
string[] deviceIDs = new string[cDevices];
devMgr.GetDevices(deviceIDs, ref cDevices);
for (int ndxDevices = 0; ndxDevices < cDevices; ndxDevices++)
{
Console.WriteLine("Device[{0}]: {1}",
ndxDevices + 1, deviceIDs[ndxDevices]);
}
}
else
{
Console.WriteLine("No WPD devices are present!");
}
}
but I get this error:
interop type 'portabledeviceapilib.portabledevicemanagerclass' Cannot be deployed
Now I'm pretty stuck.
If you could help me with this code / give me an idea of what I should do, it’s bad to be happy
all I need to do is get what type of USB is connected, if the phone is connected, or a mouse. I want to know what is connected.
Thanx ahead
source
share