.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

How to get USB drive letter of given VID PID

Posted By: balram     Posted Date: April 16, 2010    Points:2   Category :Windows Application
i have to find Vendor id and product id of connected usb drive and then their dive letter (like e:,g:),i can find vendor id and product id of connected device very easily using wmi and .net,but how to get their volume name of specified vendor id ,product id...


Author: Sagar Pardeshi             
Posted Date: April 17, 2010     Points: 5   

/ browse all USB WMI physical disks

foreach(ManagementObject drive in new ManagementObjectSearcher(
"select * from Win32_DiskDrive where InterfaceType='USB'").Get())
// associate physical disks with partitions

foreach(ManagementObject partition in new ManagementObjectSearcher(
"ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" + drive["DeviceID"]
+ "'} WHERE AssocClass =
Console.WriteLine("Partition=" + partition["Name"]);

// associate partitions with logical disks (drive letter volumes)

foreach(ManagementObject disk in new ManagementObjectSearcher(
"ASSOCIATORS OF {Win32_DiskPartition.DeviceID='"
+ partition["DeviceID"]
+ "'} WHERE AssocClass =
Console.WriteLine("Disk=" + disk["Name"]);

// this may display nothing if the physical disk

// does not have a hardware serial number

+ new ManagementObject("Win32_PhysicalMedia.Tag='"
+ drive["DeviceID"] + "'")["SerialNumber"]);

Author: balram             
Posted Date: April 17, 2010     Points: 5   

Thanks buddy..

but i already did this job..

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend