通过访问硬盘序列号来保护软件

发布于 2024-07-09 13:56:05 字数 66 浏览 8 评论 0原文

我想获得VB.NET或VB代码来在启动程序时访问硬盘序列号。 它是为了帮助我保护我自己的软件免遭试图盗版的人的侵害。

I want to get the VB.NET or VB code to access the hard disk serial no when starting the program. It's to help me to protect my own software from people who try to pirate copies.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

尴尬癌患者 2024-07-16 13:56:06

在 C# 中,但你明白了。 为此,您需要使用 System.Management:

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

正如其他人指出的那样,这可能不是处理此问题的最佳方法。 不过,那是你的事。

In c#, but you get the idea. You'll 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 might not be the best way to handle this. However, that's your business.

月亮邮递员 2024-07-16 13:56:06

抱歉,我无法向您提供代码,但我根据我之前在该领域的经验提供了一个警告。

许多许可系统使用的“硬盘序列号”实际上是写在磁盘上的软编号,而不是硬连线到硬件中。

使用“幽灵”软件快速生产许多台式机或使用虚拟化软件快速生产许多服务器的企业通常具有相同的硬盘驱动器标识。

因此,如果您的目标是阻止企业购买一份副本并在许多机器上(可能是无意的)使用它,请务必小心。

I can't offer you the code, sorry, but instead I provide a warning based on my previous experience in the area.

The "Hard Disk Serial No" that was used by a number of licensing systems is actually a soft number that is written on the disk, not hardwired into the hardware.

Enterprises that used "ghosting" software to quickly churn out many desktop machines, or virtualisation software to quickly churn out many servers often had identical Hard Drive identification.

So beware if your goal is to prevent enterprises from buying one copy and using it (perhaps unintentionally) on many machines.

本王不退位尔等都是臣 2024-07-16 13:56:06

人们经常需要升级/更换硬盘。
最好使用 DMI 中的序列号。

People often need to upgrade/replace their hard disk.
Better to use the serial number from the DMI.

偷得浮生 2024-07-16 13:56:06

事实上,我已经使用磁盘序列号来保护我的软件。

在vb 6.0中,我们可以创建并使用FileSystemObject。 它允许访问硬盘驱动器的序列号,以及其他几个功能:

  • 显示每个硬盘的已用空间和可用空间
  • 创建、删除、移动文件夹
  • 复制文件和文件夹
  • 打印文本文件
  • ...等。

请注意,在编写代码之前并声明您必须激活的对象

Project--> References --> Microsoft Scripting Runtime

以下代码提取有关驱动器的一些信息,但您也可以提取驱动器的序列号。

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

如果您仍然需要它,请在 [电子邮件受保护][电子邮件受保护]。 我会把源代码发给你。

In fact I have used disk serial number for protecting my softwares.

In vb 6.0, we can create and use FileSystemObject. It allows accessing the hard drives' serial numbers, plus several other functions:

  • displaying the used and free space of each hard disk
  • Creating, Deleting, moving folders
  • copying files and folders
  • printing text files
  • ... etc.

Note that prior to writing the code and declaring the object you must activate

Project--> References --> Microsoft Scripting Runtime

The following code extracts some info about the drive but you can also extract the serial number of the drive.

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 it, please drop a note to me at [email protected] or [email protected]. I'll send you the source code.

找个人就嫁了吧 2024-07-16 13:56:06

请在下面找到您问题的确切答案:

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

Please find below 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文