Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HDD Serial Number AGAIN

Status
Not open for further replies.

rottek

Technical User
Aug 25, 2001
8
IT
In my previous question (dated 08/25/01)I asked for:

Is there the possibility to "read" from access 2000, with a visual basic routine, the hard disk serial number to use it for a security routine to prevent the copy of the software to another computer? Thanks for your help.

The replay was:
Checkout the GetVolumeInformation API call for Win32.

Now, I was not able to find any "help" about the Api call in the Access help (I am not a good programmer, and I also don't know what an API call is).
Is it possible to have more explanation on how to use this call and make it run in the access visual basic code? Or it is possible to have a writed routine that returns the hard disck serial number.? My OS is WinNT4.
Thank you very much in advance for your patience.

 
Hi!

Here is function for several drive attributes messaging. You can choice one of them, too (ie. change this function).

Function ShowDriveInfo(DrvLetter)
'Return string with drive information
'Useful use on message box
'Try this:
'Msgbox ShowDriveInfo("C")
'-----------------------------

On Error Resume Next
Dim fs, D, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set D = fs.GetDrive(DrvLetter)
s = "Drive " & D.DriveLetter & ":"
s = s & vbLf & vbLf
If D.DriveType = 3 Then
s = s & "Share Name: " & D.ShareNames & vbLf
Else
s = s & "Label: " & D.VolumeName & vbLf
End If
s = s & "Type: "
Select Case D.DriveType
Case 0: s = s & " Unknown" & vbLf
Case 1: s = s & " Removable" & vbLf
Case 2: s = s & " Local disk" & vbLf
Case 3: s = s & " Network Share" & vbLf
Case 4: s = s & " CD-ROM" & vbLf
Case 5: s = s & " RAM Disk" & vbLf
End Select
s = s & "Serial number: " & D.SerialNumber & vbLf
s = s & "File system: " & D.FileSystem & vbLf
s = s & "Total Size: " & Int(D.TotalSize / 1024) & " Kbytes" & vbLf
s = s & "Used space: " & Int((D.TotalSize - D.FreeSpace) / 1024) & " Kbytes" & vbLf
s = s & "Available: " & Int(D.AvailableSpace / 1024) & " Kbytes" & vbLf
'Same d.FreeSpace
ShowDriveInfo = s
End Function


Example:
MsgBox ShowDriveInfo("C"), , "Drive info"


Aivars
 
In order to run the code supplied by Aivars, you need to add the Microsoft Scripting Runtime Library to your References.

Click -> Tools -> References while you have a module open in Design View, locate Microsoft Scripting Runtime in the list, and click on the checkbox next to it.

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top