Results 1 to 4 of 4

Thread: Quicky for someone clever than me!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Peterborough, UK
    Posts
    160

    Talking Quicky for someone clever than me!

    Anyone know how to access the serial number and/or model number of the c: drive on the host machine (i.e. the root of app.path)?

    HELP.

    Thanx

    Pigmy

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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    Peterborough, UK
    Posts
    160
    Wow,

    Comprehensive and FAST too!!!!

    Thanx a Million!


    Pigmy
    Remember - The light at the end of the tunnel could well be an on-coming train !

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    My pleasure....

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