In fact, I used the serial number of the drive to protect my programs.
In vb 6.0 we can create and use FileSystemObject. It allows you to access the serial numbers of hard drives and several other functions:
- display of used and free space on each hard drive
- Create, delete, move folders
- copy files and folders
- print text files
- ... etc.
Please note that before writing code and declaring an object, you must activate
Project--> References --> Microsoft Scripting Runtime
The following code retrieves some disk information, but you can also extract the serial number of the disk.
Sub ShowDriveInfo(path) Dim fso, drv, bytesPerGB, freeGB, totalGB, s s = "" bytesPerGB = 1024 * 1024 * 1024 Set fso = CreateObject("Scripting.FileSystemObject") Set drv = fso.GetDrive(fso.GetDriveName(path)) s = s & drv.Path & " - " if drv.IsReady Then freeGB = drv.FreeSpace / bytesPerGB totalGB = drv.TotalSize / bytesPerGB s = s & FormatNumber(freeGB, 3) + " GB free of " s = s & FormatNumber(totalGB, 3) + " GB" Else s = s & "Not Ready" End If s = s & "<br />" document.write (s) End Sub
If you still need to, write me an email at iranshahrinst@yahoo.com or masoodraji@aol.com. I will send you the source code.
source share