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 possible to check that specific USB card is inserted on windows using .NET 2.0? how?
if I find it through WMI, can I somehow determine which drive letter the USB drive is on?
You may be able to get this information through WMI. Below is a vbs script (copy to text file with .vbs to run) which uses WMI to get some information about Win32_DiskDrive objects. The Manufacturer info might just say Standard Disk Drive, but the Model number may have what you are looking for.
You could use unmanaged Win32 API calls to handle this.
http://www.codeproject.com/KB/system/EnumDeviceProperties.aspx
EDIT: Added code to print drive letter.
Check if this example works for you. It uses WMI.
The full code sample:
I think those properties should help you distinguish genuine USB drives from the others. Test with several pen drives to check if the values are the same. See full reference for Win32_DiskDrive properties here:
http://msdn.microsoft.com/en-us/library/aa394132(VS.85).aspx
Check if this article is also of any help to you:
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/48a9758c-d4db-4144-bad1-e87f2e9fc979
Hi try this in using WMI
Modelcould be more helpful than Manufacturer. You look at FirmwareRevision if you want to lock you app now to only one Manufacturer and one (some) Firmware Revision.
Hope it helps.
Going through either Win32 CM_ (Device Management) or WMI and grabbing the PNP ID. Look for VID (Vendor ID).
I see information for the device I just inserted under
Win32_USBControllerDevice
andWin32_DiskDrive
.Perhaps #usblib:
http://www.icsharpcode.net/OpenSource/SharpUSBLib/