There is no hard drive to protect the software by accessing the serial number of the hard drive

I want to get a VB.NET or VB code to access the serial number of the hard drive when the program starts. This will help me protect my software from people trying pirated copies.

+3
source share
5 answers

In C #, but you get this idea. You want to use System.Management for this:

string driveLetter = Environment.SystemDirectory.Substring(0, 2); string sn = new System.Management.ManagementObject("Win32_LogicalDisk.DeviceID=\"" + driveLetter + "\"").GetPropertyValue("VolumeSerialNumber").ToString(); 

As others have pointed out, this may not be the best way to handle this. However, that is your business.

+7
source

I cannot offer you the code, sorry, but instead I will provide a warning based on my previous experience in this area.

The "Serial No Hard Drive", which was used by several licensing systems, is actually a soft number written to the disk, not hardware.

Businesses that used ghosting software to quickly retrieve many desktop computers or virtualization software to quickly retrieve many servers often had the same identification on their hard drive.

Therefore, be careful if your goal is to prevent enterprises from buying one copy and using it (possibly inadvertently) on many machines.

+3
source

People often need updating / replacing a hard drive. It is better to use the serial number from DMI.

+2
source

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.

+1
source

Below you will find the exact answer to your question:

 Function ShowDriveInfo(drvpath) Dim fso, d, s, t Set fso = CreateObject("Scripting.FileSystemObject") Set d = fso.GetDrive(fso.GetDriveName(fso.GetAbsolutePathName(drvpath))) Select Case d.DriveType Case 0: t = "Unknown" Case 1: t = "Removable" Case 2: t = "Fixed" Case 3: t = "Network" Case 4: t = "CD-ROM" Case 5: t = "RAM Disk" End Select s = "Drive " & d.DriveLetter & ": - " & t s = s & "<BR>" & "SN: " & d.SerialNumber ShowDriveInfo = s End Function 
0
source

All Articles