Results 1 to 7 of 7

Thread: Get HDD Serial with .Net

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    Get HDD Serial with .Net

    What is the easiest way to get some machine specifice serial number with VB.Net?

    I've searched the forums, all of the examples I found are using VB6...

    I would like to use something like the processor or motherboard, but I would settle for the hard drive's serial number.

    Thanks for your posts,

    Squirrelly1
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Quick search brought up these threads :
    http://www.vbforums.com/search.php?s...der=descending

  3. #3
    Junior Member
    Join Date
    Apr 2004
    Posts
    19
    WMI (Windows Management Instrumentation) Objects are your friend

    you'd be surprised what you can do with WMI and Performance Counter Objects as well

    You can eliminate tons of API code from your programs
    www.mod2software.com
    Home of the VB.NET Class Builder Utility - Demo and Full versions available now!

  4. #4
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401
    try this:

    Code:
    Imports Scripting
    
        Public Function GetLicenceHDDSerialNumber() As String
            Dim fso As New FileSystemObject()
            GetLicenceHDDSerialNumber = fso.GetDrive("C").SerialNumber.ToString
        End Function
    "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

  5. #5
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    I tried, for my curiosity, but it doesn't obtain my HD serial number, but a negative number that probably is the volume number. I had the same result using a procedure that specifically obtain the volume number. With your procedure, as well as using the other one, I can obtain also another number, from the partition E: of the same HD, but serial HD number is unique on the same Disc.
    Live long and prosper (Mr. Spock)

  6. #6
    Hyperactive Member Chathura's Avatar
    Join Date
    Nov 2005
    Location
    Sri Lanka
    Posts
    345

    Re: Get HDD Serial with .Net

    Yes. This gives only the serial no of the relevent partition. I also want to know how to get the HDD serial no.

    Thanx
    If the post is heplful, Please Rate it
    Chathura Wijekoon

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Get HDD Serial with .Net

    Quote Originally Posted by Chathura
    Yes. This gives only the serial no of the relevent partition. I also want to know how to get the HDD serial no.

    Thanx
    WMI is indeed the way to go. Take a look at the Win32_DiskDrive class. I did this myself a while back and I seem to recall that I had to use the Win32_PhysicalMedia and Win32_DiskDrivePhysicalMedia classes too. Just be aware that if a system is running a RAID array then you will not be able to get the individual serial numbers as the entire array is seen as a hard drive. I never did find a way around that.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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