Results 1 to 6 of 6

Thread: HD Serial

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2001
    Location
    Brazil
    Posts
    65

    HD Serial

    hi all,
    There's a way to get the hd serial in vb?

  2. #2
    Addicted Member
    Join Date
    Feb 2001
    Posts
    217
    I think you can do that using WMI

    Here is how you get the MB serial
    Should be similar, just go over so WMI howto's

    VB Code:
    1. Public Function MBSerialNumber() As String
    2.  
    3. 'RETRIEVES SERIAL NUMBER OF MOTHERBOARD
    4. 'IF THERE IS MORE THAN ONE MOTHERBOARD, THE SERIAL
    5. 'NUMBERS WILL BE DELIMITED BY COMMAS
    6.  
    7. 'YOU MUST HAVE WMI INSTALLED AND A REFERENCE TO
    8. 'Microsoft WMI Scripting Library IS REQUIRED
    9.  
    10. Dim objs As Object
    11.  
    12. Dim obj As Object
    13. Dim WMI As Object
    14. Dim sAns As String
    15.  
    16.  
    17. Set WMI = GetObject("WinMgmts:")
    18. Set objs = WMI.InstancesOf("Win32_BaseBoard")
    19. For Each obj In objs
    20.   sAns = sAns & obj.SerialNumber
    21.  If sAns < objs.Count Then sAns = sAns & ","
    22. Next
    23. MBSerialNumber = sAns
    24. End Function

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2001
    Location
    Brazil
    Posts
    65

    Not Found !

    I'm searching information about wmi in msdn, but's there's no one of vb... Just things for C++....

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2001
    Location
    Brazil
    Posts
    65

    I found !!

    I found the information !
    It's a API !
    If someone need it, look at:
    http://www.merrioncomputing.com/Even...lume_CODE.html

  5. #5
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    I was just going to suggest looking there ;-)
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. 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
    2.  
    3. Private Sub GetVolume(PathName As String, DrvVolumeName As String, DrvSerialNo As String)  
    4.    Dim r As Long
    5.    Dim pos As Integer
    6.    Dim hword As Long
    7.    Dim HiHexStr As String
    8.    Dim lword As Long
    9.    Dim LoHexStr As String
    10.    Dim VolumeSN As Long
    11.    Dim MaxFNLen As Long
    12.    Dim UnusedStr As String
    13.    Dim UnusedVal1 As Long
    14.    Dim UnusedVal2 As Long
    15.   'pad the strings
    16.    DrvVolumeName$ = Space$(14)
    17.    UnusedStr$ = Space$(32)
    18.   'do what it says
    19.    r = GetVolumeInformation(PathName, DrvVolumeName, Len(DrvVolumeName), VolumeSN&, UnusedVal1, UnusedVal2, UnusedStr, Len(UnusedStr$))
    20.   'error check
    21.    If r& = 0 Then Exit Sub
    22.   'determine the volume label
    23.    pos = InStr(DrvVolumeName, Chr$(0))
    24.    If pos Then DrvVolumeName = Left$(DrvVolumeName, pos - 1)
    25.    If Len(Trim$(DrvVolumeName)) = 0 Then DrvVolumeName = "(no label)"
    26.    hword = HiWord(VolumeSN)
    27.    lword = LoWord(VolumeSN)
    28.    HiHexStr = Format$(Hex(hword), "0000")
    29.    LoHexStr = Format$(Hex(lword), "0000")
    30.    DrvSerialNo = HiHexStr & "-" & LoHexStr
    31. End Sub
    32.  
    33. Private Function HiWord(dw As Long) As Integer  
    34.     HiWord = (dw And &HFFFF0000) \ &H10000
    35. End Function
    36.  
    37. Private Function LoWord(dw As Long) As Integer  
    38.     If dw And &H8000& Then
    39.         LoWord = dw Or &HFFFF0000
    40.     Else
    41.         LoWord = dw And &HFFFF&
    42.     End If    
    43. End Function
    44.  
    45. Private Sub Command1_Click()
    46. 'To Display The Volume Name And Serial Number:
    47. Dim PathName As String
    48.    Dim DrvVolumeName As String
    49.    Dim DrvSerialNo As String
    50.    PathName$ = "c:\"
    51.    GetVolume PathName, DrvVolumeName, DrvSerialNo
    52.    MsgBox "Drive Statistics for " & UCase$(PathName) & ": " & "Volume Label " & DrvVolumeName & ", " & "Volume Serial No " & DrvSerialNo
    53. End Sub

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