locked
How to get Serial number on usb flash drive

    Question

  • I am unable to get the serial number on usb flash drives. I'm using vC#.net,  but I don't know what to use for get it.

    I need your help, please! Thanks all..!

    Tuesday, August 29, 2006 10:36 AM

Answers

  • I actually tried with WMI just now and for my flash USB disk there was no serial number, apperently some USB flash drives do have them, some don't.

    Give this a shot:

     



    //import the System.Management namespace at the top in your "using" statement. Then in a method, or on a button click:
     
    ManagementObjectSearch theSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE InterfaceType='USB'");
    foreach (ManagementObject currentObject in theSearcher.Get())
    {
       ManagementObject theSerialNumberObjectQuery = new ManagementObject("Win32_PhysicalMedia.Tag='" + currentObject["DeviceID"] + "'");
       MessageBox.Show(theSerialNumberObjectQuery["SerialNumber"].ToString());
    }

     

    Tuesday, August 29, 2006 5:08 PM

All replies

  • you may wish to use WMI for this, but could be overkill.

    ill see what I can dig up

    Tuesday, August 29, 2006 10:52 AM
  • Check this thread...
    Tuesday, August 29, 2006 4:30 PM
    Moderator
  • in addition to NoBugz answer (good find by the way!)... what serial number are you looking for?

    are you looking for the volume serial number or the unique serial number?

    Tuesday, August 29, 2006 4:51 PM
  • I actually tried with WMI just now and for my flash USB disk there was no serial number, apperently some USB flash drives do have them, some don't.

    Give this a shot:

     



    //import the System.Management namespace at the top in your "using" statement. Then in a method, or on a button click:
     
    ManagementObjectSearch theSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE InterfaceType='USB'");
    foreach (ManagementObject currentObject in theSearcher.Get())
    {
       ManagementObject theSerialNumberObjectQuery = new ManagementObject("Win32_PhysicalMedia.Tag='" + currentObject["DeviceID"] + "'");
       MessageBox.Show(theSerialNumberObjectQuery["SerialNumber"].ToString());
    }

     

    Tuesday, August 29, 2006 5:08 PM
  • thankz a lot..it help me lot..i got what i want to..tenkz.
    Thursday, January 11, 2007 2:28 AM
  • I've got an article on exactly this subject at http://home.hot.rr.com/graye/Articles/USB_SerialNumbers.htm

     

    It describes both a Windows Management Instrumentation (WMI) method and API method.

     

    It also has both a VB.Net and C# downloadable source code example solutions.

    Friday, May 18, 2007 8:24 PM
  • HI Graye,

     

    Do you mind if you convert your code in C++. Please kindly confirm as we urgently needing this.

     

    Thanks,

    Creative Design Studios

    Monday, September 08, 2008 1:59 AM
  • Hey,

     

    If you still need help converting, contact us at Boomer Labs and we might be able to help out.

     

    Thanks,

     

    Matt Kaustinen

    Boomer Labs

    Friday, October 03, 2008 9:14 PM
  • El segundo codigo de aqui si funciona :

    http://www.emmet-gray.com/Articles/USB_SerialNumbers.htm

    Thursday, September 30, 2010 2:02 PM