Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Get HDD Serial Number

Get HDD Serial Number

Scheduled Pinned Locked Moved Visual Basic
question
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    V 2
    wrote on last edited by
    #1

    Hi, I wanna to get hard disk serial number i m using this code it work well in my pc but in client pc it doesn't give hdd serial no i don't know that given number belogs to which physical media? Dim mgmtobj As New ManagementObject Dim searcher As ManagementObjectSearcher searcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia") For Each mgmtobj In searcher.Get If mgmtobj("SerialNumber") = Nothing Then serial = "" Else serial = mgmtobj("SerialNumber").ToString.Trim End If Next Really its very urgent for me now Thanks

    The Great Pleasure In Doing That Things That Other People Say U Can't By Doing This U Can Shut Their Mouth

    L C V V 5 Replies Last reply
    0
    • V V 2

      Hi, I wanna to get hard disk serial number i m using this code it work well in my pc but in client pc it doesn't give hdd serial no i don't know that given number belogs to which physical media? Dim mgmtobj As New ManagementObject Dim searcher As ManagementObjectSearcher searcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia") For Each mgmtobj In searcher.Get If mgmtobj("SerialNumber") = Nothing Then serial = "" Else serial = mgmtobj("SerialNumber").ToString.Trim End If Next Really its very urgent for me now Thanks

      The Great Pleasure In Doing That Things That Other People Say U Can't By Doing This U Can Shut Their Mouth

      L Offline
      L Offline
      leckey 0
      wrote on last edited by
      #2

      Please read the forum guidelines. Using 'urgent' in your message (or title) is frowned upon and my get you ignored completely.

      New feature! Scroll down to see CP offenders! Upcoming blogs: "My cats are evil." http://craptasticnation.blogspot.com/[^]

      1 Reply Last reply
      0
      • V V 2

        Hi, I wanna to get hard disk serial number i m using this code it work well in my pc but in client pc it doesn't give hdd serial no i don't know that given number belogs to which physical media? Dim mgmtobj As New ManagementObject Dim searcher As ManagementObjectSearcher searcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia") For Each mgmtobj In searcher.Get If mgmtobj("SerialNumber") = Nothing Then serial = "" Else serial = mgmtobj("SerialNumber").ToString.Trim End If Next Really its very urgent for me now Thanks

        The Great Pleasure In Doing That Things That Other People Say U Can't By Doing This U Can Shut Their Mouth

        C Offline
        C Offline
        Chinners
        wrote on last edited by
        #3

        I have this code in my library for getting the HDD serial number. I know its not the best code - I cant remember where I got it from, but it does seem to work on the few machines I have tested it with:

             Dim mobjSearcher As New ManagementObjectSearcher("SELECT \* FROM Win32\_LogicalDisk WHERE Name = 'C:'")
             For Each obj As ManagementObject In mobjSearcher.Get
                Return obj("VolumeSerialNumber").ToString
             Next
             Return "00000000000000"
        

        Maybe it will work for you?

        1 Reply Last reply
        0
        • V V 2

          Hi, I wanna to get hard disk serial number i m using this code it work well in my pc but in client pc it doesn't give hdd serial no i don't know that given number belogs to which physical media? Dim mgmtobj As New ManagementObject Dim searcher As ManagementObjectSearcher searcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia") For Each mgmtobj In searcher.Get If mgmtobj("SerialNumber") = Nothing Then serial = "" Else serial = mgmtobj("SerialNumber").ToString.Trim End If Next Really its very urgent for me now Thanks

          The Great Pleasure In Doing That Things That Other People Say U Can't By Doing This U Can Shut Their Mouth

          C Offline
          C Offline
          Chinners
          wrote on last edited by
          #4

          But - the obvious mistake you have made is... If you find more than one drive in your search, and the SECOND drive doesnt have a serial number (for whatever reason), you are clearing the serial number... Oops? Thats the problems with for...next loops setting variables.

          1 Reply Last reply
          0
          • V V 2

            Hi, I wanna to get hard disk serial number i m using this code it work well in my pc but in client pc it doesn't give hdd serial no i don't know that given number belogs to which physical media? Dim mgmtobj As New ManagementObject Dim searcher As ManagementObjectSearcher searcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia") For Each mgmtobj In searcher.Get If mgmtobj("SerialNumber") = Nothing Then serial = "" Else serial = mgmtobj("SerialNumber").ToString.Trim End If Next Really its very urgent for me now Thanks

            The Great Pleasure In Doing That Things That Other People Say U Can't By Doing This U Can Shut Their Mouth

            V Offline
            V Offline
            V 2
            wrote on last edited by
            #5

            First of all thanks to all for reply I know its not good to say "Urgent" but its really very very urgent for me so i had to wrote Thanks Jasey9 for your code but.... Return obj("VolumeSerialNumber").ToString I have already tried it but it will return the volume number of a particular Drive like C: but after format the Pc it will change so i need only the serial number of hard disk Is there any way to varify that the number returned by searcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia") is hard disk serial number,I need your guidance... Thanks

            The Great Pleasure In Doing That Things That Other People Say U Can't By Doing This U Can Shut Their Mouth

            1 Reply Last reply
            0
            • V V 2

              Hi, I wanna to get hard disk serial number i m using this code it work well in my pc but in client pc it doesn't give hdd serial no i don't know that given number belogs to which physical media? Dim mgmtobj As New ManagementObject Dim searcher As ManagementObjectSearcher searcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia") For Each mgmtobj In searcher.Get If mgmtobj("SerialNumber") = Nothing Then serial = "" Else serial = mgmtobj("SerialNumber").ToString.Trim End If Next Really its very urgent for me now Thanks

              The Great Pleasure In Doing That Things That Other People Say U Can't By Doing This U Can Shut Their Mouth

              V Offline
              V Offline
              Vimalsoft Pty Ltd
              wrote on last edited by
              #6

              hi What do you want to do with a HDD Serial number, for sure it changes when the HDD get formated. its not Stable, if you want this for Software protection thing, then i think you should go for Processor ID, that will never change. Thanks

              Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups