I need my program to work only with certain USB Flash drives (from a single manufacturer) and ignore all other USB Flash drives (from any other manufacturers).
is it
Perhaps #usblib:
http://www.icsharpcode.net/OpenSource/SharpUSBLib/
Just in case anyone else is crazy enough to do this in C++-CLI, here's a port of smink's answer:
using namespace System;
using namespace System::Management;
void GetUSBDeviceList()
{
try
{
ManagementObjectSearcher^ searcher =
gcnew ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_DiskDrive");
for each (ManagementObject^ queryObj in searcher->Get())
{
Console::WriteLine("DeviceID: {0}", queryObj["DeviceID"]);
Console::WriteLine("PNPDeviceID: {0}", queryObj["PNPDeviceID"]);
Console::WriteLine("Manufacturer: {0}", queryObj["Manufacturer"]);
Console::WriteLine("Model: {0}", queryObj["Model"]);
for each (ManagementObject^ b in queryObj->GetRelated("Win32_DiskPartition"))
{
Console::WriteLine(" Name: {0}", b["Name"]);
for each (ManagementBaseObject^ c in b->GetRelated("Win32_LogicalDisk"))
{
Console::WriteLine(" Name: {0}", c["Name"]); // here it will print drive letter
}
}
// ...
Console::WriteLine("--------------------------------------------");
}
}
catch (ManagementException^ e)
{
Console::WriteLine(e->StackTrace);
}
Console::ReadLine();
}
Note: I had to manually add a reference to the System.Management
library in my porject properties.