如何获取PC唯一ID?

发布于 2024-12-06 20:49:36 字数 113 浏览 1 评论 0原文

  1. PC唯一ID是什么?
  2. 我们怎样才能得到PC的唯一ID呢?
  3. 是硬盘还是主板的问题?

我想将 PC ID 存储在我的窗口程序中。请分享我。

  1. What is the PC unique ID?
  2. How could we get the PC unqiue ID?
  3. Is it about Hard disk or motherboard?

I'd like to store PC ID in my window program. Please share me.

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

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

发布评论

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

评论(5

傾城如夢未必闌珊 2024-12-13 20:49:36

这对我来说很有效,

Private Function CpuId() As String
    Dim computer As String = "."
    Dim wmi As Object = GetObject("winmgmts:" & _
        "{impersonationLevel=impersonate}!\\" & _
        computer & "\root\cimv2")
    Dim processors As Object = wmi.ExecQuery("Select * from " & _
        "Win32_Processor")

    Dim cpu_ids As String = ""
    For Each cpu As Object In processors
        cpu_ids = cpu_ids & ", " & cpu.ProcessorId
    Next cpu
    If cpu_ids.Length > 0 Then cpu_ids = _
        cpu_ids.Substring(2)

    Return cpu_ids
End Function

请参阅此处

This work for me

Private Function CpuId() As String
    Dim computer As String = "."
    Dim wmi As Object = GetObject("winmgmts:" & _
        "{impersonationLevel=impersonate}!\\" & _
        computer & "\root\cimv2")
    Dim processors As Object = wmi.ExecQuery("Select * from " & _
        "Win32_Processor")

    Dim cpu_ids As String = ""
    For Each cpu As Object In processors
        cpu_ids = cpu_ids & ", " & cpu.ProcessorId
    Next cpu
    If cpu_ids.Length > 0 Then cpu_ids = _
        cpu_ids.Substring(2)

    Return cpu_ids
End Function

see here

∝单色的世界 2024-12-13 20:49:36

试试这个,它会从处理器中提取 ID。

Dim win32MgmtClass as System.Management.ManagementClass
win32MgmtClass = new System.Management.ManagementClass("Win32_Processor")
Dim processors as System.Management.ManagementObjectCollection
processors = win32MgmtClass.GetInstances()

For Each processor As System.Management.ManagementObject In processors
    MessageBox.Show(processor("ProcessorID").ToString())
Next

Try this, it pulls the ID off the processor.

Dim win32MgmtClass as System.Management.ManagementClass
win32MgmtClass = new System.Management.ManagementClass("Win32_Processor")
Dim processors as System.Management.ManagementObjectCollection
processors = win32MgmtClass.GetInstances()

For Each processor As System.Management.ManagementObject In processors
    MessageBox.Show(processor("ProcessorID").ToString())
Next
一梦等七年七年为一梦 2024-12-13 20:49:36

我假设您想要生成一个机器唯一的 ID。硬盘驱动器可能是最简单的方法,因为其他硬件过于多样化,无法有一套检索其序列号的方法。

最简单的方法可能是使用 Windows 为硬盘驱动器生成的编号。

您可以在 HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices 下找到它
键名是 \DosDevices\C: (假设 C: 驱动器是主系统驱动器 - 在极少数情况下并非如此,但您可以检查系统驱动器是什么并使用适当的键)。

还有另一个与硬盘驱动器相关的数字,称为 UUID,您可以找到脚本来获取该数字。例如: http://www.windowsnetworking.com/articles_tutorials/Deploying -Windows-7-Part18.html 适用于 Windows。或者http://blog.granneman。 com/2007/07/26/find-out-a-hard-drives-uuid/(适用于 Linux)。

我还找到了这篇关于检索主板序列号的文章:获取主板唯一 ID通过vc++编程实现数字

I assume that you want to generate an ID that is unique to the machine. Hard drive is probably the easiest approach because other hardware is too diverse to have a set way of retrieving their serial numbers.

Probably the easiest is to use the number that Windows generates for the hard drive.

You can find it under HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices
and the key name is \DosDevices\C: (assuming that the C: drive is the main system drive - which is not the case in some very rare cases, but then you can check for what the system drive is and use the appropriate key).

There's another number associated with Hard drives called UUID and you can find scripts to get that. For example: http://www.windowsnetworking.com/articles_tutorials/Deploying-Windows-7-Part18.html for Windows. Or http://blog.granneman.com/2007/07/26/find-out-a-hard-drives-uuid/ for Linux.

I also found this article on retrieving the motherboard's serial number: Getting motherboard unique ID number thru vc++ programming

蓝海 2024-12-13 20:49:36

“PC唯一ID”通常是指硬件ID,用于唯一标识一台计算机。例如,它们可用于跟踪计算机上软件的使用情况。

根据 这个问题,“主板id、处理器id和BIOS id”“是最不可能改变的”。

此问题包含获取此类信息的代码在 C# 中;不幸的是,我找不到 VB.NET 的任何主题,但它应该很容易移植。

The "PC unique ID" normally means the hardware ID, used to uniquely identify a computer. For example, they can be used to track software use on computers.

According to this question, the "motherboard id, processor id and bios id" "are the least likely to change".

This question contains code to get such information in C#; I couldn't find any topics for VB.NET, unfortunately, but it should be easy to port.

蓬勃野心 2024-12-13 20:49:36

需要
https://www.nuget.org/packages/System.Management/

系统.管理4.7.0

正如您所看到的,有一个“唯一值”加上一些特殊的计算。你可以尽可能地让它变得困难,但逆向工程最终可能会暴露这一点。

计算机 ID 的更好(但更慢)版本(需要 System.Management 导入和引用):
代码:

    Public Shared Function GetComputerID() As Long
        Dim objMOS As New ManagementObjectSearcher("Select * From Win32_Processor")
        For Each objMO As Management.ManagementObject In objMOS.Get
            GetComputerID += objMO("ProcessorID").GetHashCode
        Next
        GetComputerID += My.Computer.Name.GetHashCode
    End Function

requires
https://www.nuget.org/packages/System.Management/

System.Management 4.7.0

As you can see there is an "Unique Value" plus some special calculations. You can make this as hard as you can, but reverse engineering can ultimately expose this.

Better (but slower) version for computer ID (requires System.Management import and reference):
Code:

    Public Shared Function GetComputerID() As Long
        Dim objMOS As New ManagementObjectSearcher("Select * From Win32_Processor")
        For Each objMO As Management.ManagementObject In objMOS.Get
            GetComputerID += objMO("ProcessorID").GetHashCode
        Next
        GetComputerID += My.Computer.Name.GetHashCode
    End Function
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文