Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 11th, 2007, 05:43 AM
Registered User
 
Join Date: Nov 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hard Disk Serial Number

How can i read the serial number of the hard disk and print it out in vb code?

asmat
 
Old December 18th, 2007, 04:26 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Look into APIs for this on Microsoft's web site.

it took me 11 seconds to find:
Code:
Private Sub Command1_Click()

    Dim root As String

    Dim volume_name As String

    Dim serial_number As Long

    Dim max_component_length As Long

    Dim file_system_flags As Long

    Dim file_system_name As String

    Dim pos As Integer

 

    root = Text1.Text

    volume_name = Space$(1024)

    file_system_name = Space$(1024)

 

    If GetVolumeInformation(root, volume_name, _

        Len(volume_name), serial_number, _

        max_component_length, file_system_flags, _

        file_system_name, Len(file_system_name)) = 0 _

    Then

        MsgBox("Error getting volume information.")

        Exit Sub

    End If

 

    pos = InStr(volume_name, Chr$(0))

    volume_name = Left$(volume_name, pos - 1)

    lblVolumeName.Caption = volume_name

 

    lblSerialNumber.Caption = Format$(serial_number)

 

    lblMaxComponentLength.Caption = _

        Format$(max_component_length)

 

    pos = InStr(file_system_name, Chr$(0))

    file_system_name = Left$(file_system_name, pos - 1)

    lblFileSystem.Caption = file_system_name

 

    lblFlags.Caption = "&&H" & Hex$(file_system_flags)

End Sub
Another couple secs to find http://msdn2.microsoft.com/en-us/library/aa364993.aspx.

Then there is http://support.microsoft.com/kb/139547. (This is C, but perhaps the info there will help, especially the text explaining the code that's posted there.)

As they say: Search the Web...





Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial Number of the Hard Disk ivanlaw Assembly Language 0 July 15th, 2007 10:15 PM
Hard Disk Serial Number preetha Ajayan C# 2005 3 June 20th, 2007 06:44 PM
how to get hard disk serial number in c# imran_mani .NET Framework 1.x 0 May 7th, 2007 03:45 AM
Hard disk serial number alexjiju VS.NET 2002/2003 1 February 3rd, 2007 02:50 PM
How to retreive Hard disk serial no gkrishn01 Java Espanol 0 December 10th, 2004 05:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.