Results 1 to 8 of 8

Thread: Old story of HDD Serial, New Issues..[Long Live WMI]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474

    Old story of HDD Serial, New Issues..[Long Live WMI]

    In a thread there was a discussion about how to get the HDD serial number. There, an API was suggested that returned the VOLUME serial number. Today I came across FileSystemObject, that by using that you can simply get the VOLUME serial number:

    After adding a reference to Microsoft Scripting Runtime COM component you can easily do that by:
    VB Code:
    1. Imports Scripting
    2.  
    3. '
    4. '
    5. Dim fso As New FileSystemObject()
    6. MessageBox.Show(fso.GetDrive("C").SerialNumber.ToString)

    As you see this method and that API call both return the Volume Serial number.
    I like to know is there a way to read the hard-coded manufacturer's hard drive serial number? Just curious to know
    Last edited by Lunatic3; Apr 1st, 2003 at 01:56 PM.

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    I dont beleive thats anywhere "in" the HD. I think the only place that exsists is on a sticker on the HD.
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    No [LGS]Static! Its not only on the sticker.

    I finally found a method to do that. Ofcourse this seems to work only under XP.
    VB Code:
    1. ' Code to read the hard coded manufactutrer Serial Number of Hard Disk
    2.  
    3. Dim mgmclass As New System.Management.ManagementClass("Win32_PhysicalMedia")
    4. Dim mgmcoll As Management.ManagementObjectCollection = mgmclass.GetInstances()
    5. Dim mgmenum As Management.ManagementObjectCollection.ManagementObjectEnumerator = mgmcoll.GetEnumerator
    6. mgmenum.MoveNext()
    7. MessageBox.Show(mgmenum.Current.Properties("SerialNumber").Value.ToString)

    In this manner you should be able to read other physical media such as CD-ROM, Floppy,... but there are some strange things I dont understand about it. Still working on that.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Cool . I can get HD Serial # with only two lines .
    Good job Lunatic3

  5. #5
    Addicted Member CoMMiE's Avatar
    Join Date
    Jul 2000
    Location
    Malaysia, Kuala Lumpur
    Posts
    179
    I have a question is the volume drive serial no and the hd serial number two diffrent thing alltogether?

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Yes, I think they are!

    HD serial number is a serial number hard coded by manufacturer and is also written on the sticker of your Hard Disk. But Volume Serial Number is given to each partition when its formatted. It will change when you reformat the partition and also can be changed without formating the partition by editing the boot sector of partion. Also when you have spanned some partitions to one Volume then they will have only one Volume Serial Number.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  7. #7
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401
    sorry,

    i think i'm missing something really obvious. i cannot seem to get this line to work:

    Code:
    Imports Scripting
    I've put it with the other Imports line but this one cannot be found. is there a "trick" to this one?

    cheers,
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

  8. #8
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401
    d'oh!



    ignore that previous post!


    Code:
    To create a reference to the Scripting type library (Scrrun.dll) 
    
    On the Project menu, click Add Reference, and then click the COM tab. 
    Choose Microsoft Scripting Runtime from the Component Name list, and then click Select. 
    You can now use the Object Browser to view the FSO model's objects, collections, properties, methods, events, and constants.
    "The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.

    Windows & Web Developer
    Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
    Sutherland Shire, Sydney Australia
    www.stingrae.com.au
    Developer of Arnold - Gym & Martial Arts Database Management System
    www.gymdatabase.com.au

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