CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002
    Posts
    121

    get the hard-drive serial number

    Does anyone know how to retrieve the hard-drive serial number?
    I tried System.Management documentation to no help.

    Any idea on how can I get at it? Any useful links? I would prefer to implement it in c#, but c++ or vb would also suffice.

    Thank you for you help!
    kd.

  2. #2
    Join Date
    May 2002
    Posts
    6

    Cool here you go bud.....

    Look into .NET & WMI documentation for more details....
    I adapted the below code from a sample given in the .NET documentation.

    using System;
    using System.Management;


    class VolumeSerialFinder
    {
    public static int Main(string[] args)
    {
    ManagementClass diskClass = new ManagementClass("Win32_LogicalDisk");
    ManagementObjectCollection disks = diskClass.GetInstances();
    foreach (ManagementObject disk in disks)
    {
    Console.WriteLine("Disk = " + disk["VolumeSerialNumber"]);
    }
    Console.ReadLine();
    return 0;
    }
    }

  3. #3
    Join Date
    May 2002
    Posts
    121
    ohh... beautiful!!!

    Thank you so much!

    I don't believe I couldn't find it through the msdn mess

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured