Hard Disk Serial Number - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Hard Disk Serial Number

badarbadar Posts: 1Member
Hi all

I want to pick my Hard-Disk Serial Number, Processor ID and Mother Board ID through my Visual Basic Code. I am working on a CD-Key for a Product.
Can anyone help me on it??????
Please let me know if there is any other thread here or any link you know.

Looking for your response anxiously,

Badar.

Comments

  • MicroDotMicroDot Posts: 142Member
    : Hi all
    :
    : I want to pick my Hard-Disk Serial Number, Processor ID and Mother Board ID through my Visual Basic Code. I am working on a CD-Key for a Product.
    : Can anyone help me on it??????
    : Please let me know if there is any other thread here or any link you know.
    :
    : Looking for your response anxiously,
    :
    : Badar.
    :

    Hi,

    Harddisk serial number:

    [code]

    Private Declare Function GetVolumeInformation _
    Lib "Kernel32" _
    Alias "GetVolumeInformationA" _
    (ByVal lpRootPathName As String, _
    ByVal lpVolumeNameBuffer As String, _
    ByVal nVolumeNameSize As Long, _
    lpVolumeSerialNumber As Long, _
    lpMaximumComponentLength As Long, _
    lpFileSystemFlags As Long, _
    ByVal lpFileSystemNameBuffer As String, _
    ByVal nFileSystemNameSize As Long) As Long

    Private Const MAX_FILENAME_LEN = 256

    Private Sub Form_Load()
    MsgBox "Serial of drive C is " & GetDriveSerial("C")
    End Sub

    Public Function GetDriveSerial(ByVal strDrv As String) As Long
    Dim lngRetVal As Long
    Dim strVNB As String * MAX_FILENAME_LEN
    Dim strFSNB As String * MAX_FILENAME_LEN
    Dim lngMCL As Long
    Dim lngFSF As Long

    Call GetVolumeInformation(strDrv & ":", _
    strVNB, _
    MAX_FILENAME_LEN, _
    lngRetVal, _
    lngMCL, _
    lngFSF, _
    strFSNB, _
    MAX_FILENAME_LEN)
    GetDriveSerial = RetVal
    End Function

    [/code]



    ProcessorID:

    [code]

    Private Sub GetCpuID()
    Dim strComputer
    Dim WMI
    Dim wmiWin32Object
    Dim wmiWin32Objects
    Dim strText

    Set WMI = GetObject("WinMgmts://" & strComputer)
    Set wmiWin32Objects = WMI.InstancesOf("Win32_Processor")

    For Each wmiWin32Object In wmiWin32Objects
    strText = "ProcessorID: " & wmiWin32Object.ProcessorId & vbCrLf
    MsgBox strText
    Next
    End Sub

    [/code]


    Hope this helps you out...


    [hr]

    [b][blue]//MicroDot[/blue][/b]

Sign In or Register to comment.