|
-
Jan 11th, 2002, 03:11 PM
#1
Thread Starter
Addicted Member
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
-
Jan 11th, 2002, 03:13 PM
#2
VB 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 Sub GetVolume(PathName As String, DrvVolumeName As String, DrvSerialNo As String)
Dim r As Long
Dim pos As Integer
Dim hword As Long
Dim HiHexStr As String
Dim lword As Long
Dim LoHexStr As String
Dim VolumeSN As Long
Dim MaxFNLen As Long
Dim UnusedStr As String
Dim UnusedVal1 As Long
Dim UnusedVal2 As Long
'pad the strings
DrvVolumeName$ = Space$(14)
UnusedStr$ = Space$(32)
'do what it says
r = GetVolumeInformation(PathName, DrvVolumeName, Len(DrvVolumeName), VolumeSN&, UnusedVal1, UnusedVal2, UnusedStr, Len(UnusedStr$))
'error check
If r& = 0 Then Exit Sub
'determine the volume label
pos = InStr(DrvVolumeName, Chr$(0))
If pos Then DrvVolumeName = Left$(DrvVolumeName, pos - 1)
If Len(Trim$(DrvVolumeName)) = 0 Then DrvVolumeName = "(no label)"
hword = HiWord(VolumeSN)
lword = LoWord(VolumeSN)
HiHexStr = Format$(Hex(hword), "0000")
LoHexStr = Format$(Hex(lword), "0000")
DrvSerialNo = HiHexStr & "-" & LoHexStr
End Sub
Private Function HiWord(dw As Long) As Integer
HiWord = (dw And &HFFFF0000) \ &H10000
End Function
Private Function LoWord(dw As Long) As Integer
If dw And &H8000& Then
LoWord = dw Or &HFFFF0000
Else
LoWord = dw And &HFFFF&
End If
End Function
'To Display The Volume Name And Serial Number:
Dim PathName As String
Dim DrvVolumeName As String
Dim DrvSerialNo As String
PathName$ = "c:\"
GetVolume PathName, DrvVolumeName, DrvSerialNo
MsgBox "Drive Statistics for " & UCase$(PathName) & ": " & "Volume Label " & DrvVolumeName & ", " & "Volume Serial No " & DrvSerialNo
-
Jan 11th, 2002, 03:15 PM
#3
Thread Starter
Addicted Member
-
Jan 11th, 2002, 03:18 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|