VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Get Serialnumber from a harddisk

by Manuel W. (3 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (8 Votes)

Get the Serialnumber from your harddisk, cd rom or your disks.

Assumes
Make a label named label1 and an commandbutton named command1.

Rate Get Serialnumber from a harddisk

Option Explicit
Private Declare Function GetVolumeInformation& Lib "kernel32" _
    Alias "GetVolumeInformationA" (ByVal lpRootPathName _
    As String, ByVal pVolumeNameBuffer As String, ByVal _
    nVolumeNameSize As Long, lpVolumeSerialNumber As Long, _
    lpMaximumComponentLength As Long, lpFileSystemFlags As _
    Long, ByVal lpFileSystemNameBuffer As String, ByVal _
    nFileSystemNameSize As Long)
Const MAX_FILENAME_LEN = 256
Private Sub Command1_Click()
 Label1.Caption = SerNum("C") 'C is the standard harddisk
End Sub
Public Function SerNum(Drive$) As Long
 Dim No&, s As String * MAX_FILENAME_LEN
  Call GetVolumeInformation(Drive + ":\", s, MAX_FILENAME_LEN, _
               No, 0&, 0&, s, MAX_FILENAME_LEN)
  SerNum = No
End Function
Private Sub Form_Load()
End Sub

Download this snippet    Add to My Saved Code

Get Serialnumber from a harddisk Comments

No comments have been posted about Get Serialnumber from a harddisk. Why not be the first to post a comment about Get Serialnumber from a harddisk.

Post your comment

Subject:
Message:
0/1000 characters