none
Serial Number USB flash drive RRS feed

  • Question

  • I didn't find the right forum to put it, so...
    Well, i'm trying to get the serial number on usb flash drive, but i've tested 3 flash drive and it always returns an empty text.
    I'm doing with this code:
    using System;
    using System.Management;
    using System.Windows.Forms;
    
    namespace WMISample
    {
        public class MyWMIQuery
        {
            public static void Main()
            {
                try
                {
                    ManagementObjectSearcher searcher = 
                        new ManagementObjectSearcher("root\\CIMV2", 
                        "SELECT * FROM Win32_DiskDrive"); 
    
                    foreach (ManagementObject queryObj in searcher.Get())
                    {
                        Console.WriteLine("-----------------------------------");
                        Console.WriteLine("Win32_DiskDrive instance");
                        Console.WriteLine("-----------------------------------");
                        Console.WriteLine("SerialNumber: {0}", queryObj["SerialNumber"]);
                    }
                }
                catch (ManagementException e)
                {
                    MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
                }
            }
        }
    }

    Get a life. Go party!
    • Moved by nobugz Saturday, June 13, 2009 10:46 PM not a wf q (From:Windows Forms General)
    Saturday, June 13, 2009 10:35 PM

Answers

All replies