Dan Violet Sagmiller (He/Him)
asked on
Hardware Serial Numbers.
My Needs:
I am trying to write a piece of software that will utilize USB Keys, to distinguish between users.
My Question:
I presume that each piece of hardware hols a serial identification, along with model or vendor info. (based on the fact that hard drives carry this)
I want to know how to access the Serial Number, and if possible, Model and vendor info for a USB key (Flash disk)
I am trying to write a piece of software that will utilize USB Keys, to distinguish between users.
My Question:
I presume that each piece of hardware hols a serial identification, along with model or vendor info. (based on the fact that hard drives carry this)
I want to know how to access the Serial Number, and if possible, Model and vendor info for a USB key (Flash disk)
ASKER
I will be programming in VB.Net. I need the application to be able to determine the Serial number of any given Drive. Specifcally, USB Flash disks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just to rewrite the function exactly as in VB6:
Public Function DriveSerialNumber(ByVal Drive As String) As Long
'usage: SN = DriveSerialNumber("C:\")
Dim lAns As Long
Dim lRet As Long
Dim sVolumeName As String = New String(Chr(0), 255)
Dim sDriveType As String = New String(Chr(0), 255)
Dim sDrive As String
'Deal with one and two character input values
sDrive = Drive
If Len(sDrive) = 1 Then
sDrive = sDrive & ":\"
ElseIf Len(sDrive) = 2 And sDrive.Substring(1) = ":" Then
sDrive = sDrive & "\"
End If
Return GetVolumeInformation(sDriv e, sVolumeName, 255, lAns, 0, 0, sDriveType, 255)
End Function
Public Function DriveSerialNumber(ByVal Drive As String) As Long
'usage: SN = DriveSerialNumber("C:\")
Dim lAns As Long
Dim lRet As Long
Dim sVolumeName As String = New String(Chr(0), 255)
Dim sDriveType As String = New String(Chr(0), 255)
Dim sDrive As String
'Deal with one and two character input values
sDrive = Drive
If Len(sDrive) = 1 Then
sDrive = sDrive & ":\"
ElseIf Len(sDrive) = 2 And sDrive.Substring(1) = ":" Then
sDrive = sDrive & "\"
End If
Return GetVolumeInformation(sDriv e, sVolumeName, 255, lAns, 0, 0, sDriveType, 255)
End Function
Sorry :) (Still works, either way :) )...
Jake
Public Function DriveSerialNumber(ByVal Drive As String) As Long
'usage: SN = DriveSerialNumber("C:\")
Dim lAns As Long
Dim lRet As Long
Dim sVolumeName As String = New String(Chr(0), 255)
Dim sDriveType As String = New String(Chr(0), 255)
Dim sDrive As String
'Deal with one and two character input values
sDrive = Drive
If Len(sDrive) = 1 Then
sDrive = sDrive & ":\"
ElseIf Len(sDrive) = 2 And sDrive.Substring(1) = ":" Then
sDrive = sDrive & "\"
End If
Return GetVolumeInformation(sDriv
End Function
Public Function DriveSerialNumber(ByVal Drive As String) As Long
'usage: SN = DriveSerialNumber("C:\")
Dim lAns As Long
Dim lRet As Long
Dim sVolumeName As String = New String(Chr(0), 255)
Dim sDriveType As String = New String(Chr(0), 255)
Dim sDrive As String
'Deal with one and two character input values
sDrive = Drive
If Len(sDrive) = 1 Then
sDrive = sDrive & ":\"
ElseIf Len(sDrive) = 2 And sDrive.Substring(1) = ":" Then
sDrive = sDrive & "\"
End If
Return GetVolumeInformation(sDriv
End Function
Sorry :) (Still works, either way :) )...
Jake
ASKER
I was hoping .NET had a specific solution, and perhaps it does. but for now it will have to wait another day.
Thank you for the assistance, and I will use the API method.
Thank you for the assistance, and I will use the API method.
hpdvs2,
I tried to find a .NET solution, however, I couldn't find one. For now, that's what you have to use. I believe that in the new 2.0 Framework there will be methods to access this directly (Not positive).
Jake
I tried to find a .NET solution, however, I couldn't find one. For now, that's what you have to use. I believe that in the new 2.0 Framework there will be methods to access this directly (Not positive).
Jake
Unless you mean just a datastick...
Jake