none
Hard Disk Serial Number

    Question

  • hi.

    i want 2 know that ,is there anyway to get hard disk serial number(Hard Disk , not Hard Drives) without using WMI.

    plz forgive me for my bad english

    go0d luCk

    Wednesday, July 05, 2006 3:13 PM

Answers

  • Hard disk and Hard drive is the same thing, just different term.

    To get the Volume label, take a look at the System.IO.DriveInfo class.

    You would get a list of drives on the system.

    for each drive, get the volumelabel of the drive.

     

    To get the serial number of a drive, I dont think this is possible in .NET unless you use WMI or perhaps call a Win32 function/PInvoke.

    try some of these resources, but they mainly refer to WMI

    http://www.microsoft.com/belux/msdn/nl/community/columns/sucaet/filesyst_en.mspx

    http://www.thecodeproject.com/csharp/hard_disk_serialno.asp

     

    You can use this to PInvoke:

    http://windowssdk.msdn.microsoft.com/en-us/library/ms685899.aspx

    Check this post on how to use it:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=357158&SiteID=1

     

    however it is best to use the .NET way of doing such things but .NET does not have a way of getting the serial number of the hard disk, unless you use WMI

     

    Wednesday, July 05, 2006 7:10 PM
    Moderator
  • Serial number is unique on each hard drive, its physically programmed on the circuit board/ROM.

     

    What you are referring to about different drives are logical partitions, which are volume numbers.

    Regardless how many logical partitions you have on a physical drive, the serial number is always the same, its built into the physical hard disk itself. The only change that will happen with the logical partitions is the volume label.

    Wednesday, July 05, 2006 8:12 PM
    Moderator
  • Try this Code or visit this link

    http://www.vbcity.com/forums/topic.asp?tid=103023

     

    Imports System.Management

     

    Dim tmpStr2 As String = ""

    Dim myScop As New Management.ManagementScope("\\" & Environment.MachineName & "\root\cimv2")

    Dim oQuer As New Management.SelectQuery("SELECT * FROM WIN32_DiskDrive")

    Dim oResult As New Management.ManagementObjectSearcher(myScop, oQuer)

    Dim oIte As Management.ManagementObject

    Dim oPropert As Management.PropertyData

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

       For Each oIte In oResult.Get()

          For Each oPropert In oIte.Properties

             If Not oPropert.Value Is Nothing AndAlso oPropert.Name = "Signature" Then

                  tmpStr2 = oPropert.Value.ToString

                  Exit For

             End If

          Next

       Next

    MsgBox(tmpStr2)

    End Sub

     

     

    Greetings

    Simão

    landsimao.hotmail.com

    Wednesday, July 05, 2006 10:16 PM

All replies

  • Hard disk and Hard drive is the same thing, just different term.

    To get the Volume label, take a look at the System.IO.DriveInfo class.

    You would get a list of drives on the system.

    for each drive, get the volumelabel of the drive.

     

    To get the serial number of a drive, I dont think this is possible in .NET unless you use WMI or perhaps call a Win32 function/PInvoke.

    try some of these resources, but they mainly refer to WMI

    http://www.microsoft.com/belux/msdn/nl/community/columns/sucaet/filesyst_en.mspx

    http://www.thecodeproject.com/csharp/hard_disk_serialno.asp

     

    You can use this to PInvoke:

    http://windowssdk.msdn.microsoft.com/en-us/library/ms685899.aspx

    Check this post on how to use it:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=357158&SiteID=1

     

    however it is best to use the .NET way of doing such things but .NET does not have a way of getting the serial number of the hard disk, unless you use WMI

     

    Wednesday, July 05, 2006 7:10 PM
    Moderator
  • thnx for your help.

    http://files.download-by.net/download/98643-hdd101.zip

    the link above is a program that get the HDD Serial Number without using WMI , it's only using API Functions to get SN of HDD.

    i want to get SN of HDD not Drives Like C: or D: .

    Go0d LuCk.

     

    Wednesday, July 05, 2006 8:06 PM
  • Serial number is unique on each hard drive, its physically programmed on the circuit board/ROM.

     

    What you are referring to about different drives are logical partitions, which are volume numbers.

    Regardless how many logical partitions you have on a physical drive, the serial number is always the same, its built into the physical hard disk itself. The only change that will happen with the logical partitions is the volume label.

    Wednesday, July 05, 2006 8:12 PM
    Moderator
  • Try this Code or visit this link

    http://www.vbcity.com/forums/topic.asp?tid=103023

     

    Imports System.Management

     

    Dim tmpStr2 As String = ""

    Dim myScop As New Management.ManagementScope("\\" & Environment.MachineName & "\root\cimv2")

    Dim oQuer As New Management.SelectQuery("SELECT * FROM WIN32_DiskDrive")

    Dim oResult As New Management.ManagementObjectSearcher(myScop, oQuer)

    Dim oIte As Management.ManagementObject

    Dim oPropert As Management.PropertyData

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

       For Each oIte In oResult.Get()

          For Each oPropert In oIte.Properties

             If Not oPropert.Value Is Nothing AndAlso oPropert.Name = "Signature" Then

                  tmpStr2 = oPropert.Value.ToString

                  Exit For

             End If

          Next

       Next

    MsgBox(tmpStr2)

    End Sub

     

     

    Greetings

    Simão

    landsimao.hotmail.com

    Wednesday, July 05, 2006 10:16 PM
  • Special thnx to all of you for your helps

    tnx Simao for your help that was very useful .

     

    Go0d LuCk

    Wednesday, July 05, 2006 11:20 PM
  • The only problem with using the "Signature" property of the WIN32_DiskDrive class is that it doesn't seem to be compatible with all operating systems.  If you take a look at the description for this property at http://msdn2.microsoft.com/en-us/library/aa394132(VS.85).aspx, it says it was added to Windows XP, meaning it didn't previously exist?  When was it added?  I tested on a Windows 2000 machine and only got errors with this property.

     

    The link to the vbCity thread "how to read the Hard disk ID" is a little confusing because it doesn't seem clear that all people posting are using the same version of Visual Basic.

     

    And people keep posting links to this adbaaz.com site "BrowseDatabase.com" for some program, but I can never find it!  If any one knows how to actually navigate through that site to the program, that's be swell.

     

    The best bit of code I found was here: http://www.vbforums.com/showthread.php?t=456757.  It's mentioned other places, but this was the only place I could actually find the downloadable HDSNLib class.  I did some tweaking to it, had to compile it, then saved it as a DLL, and simply reference it in my project.  This download on that page also has a sample program to show how to use the DLL properly.  I've seen this work with 2000, XP, and Vista (must have administrative privileges, which gets a little tricky with Vista, but it works).

     

     

    Saturday, March 08, 2008 5:02 AM
  • Thanks for this info guys. Been struggling to find the serial number labels on my hard drives too. This has helped me no end. Especially your link simao,

    Thanks again

    Friday, May 28, 2010 11:47 AM