5
  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.

KV Prajapati
  • 93,659
  • 19
  • 148
  • 186
soclose
  • 2,773
  • 12
  • 51
  • 60
  • 1
    This doesn't discuss the VB specific implementation, but it does describe the various options: http://stackoverflow.com/questions/671876/whats-a-good-way-to-uniquely-identify-a-computer – mal-wan Sep 26 '11 at 03:30
  • 1
    There is no a "PC unique ID". Some PC parts have serial ID, like CPU, hard disk, motherboard, network card... but user can replace that part and then you get a new ID. Try to be more specific about your goal. – David Oliván Sep 26 '11 at 03:36
  • Why do you want to store a unique ID for that PC? What would you be using this for? – briddums Sep 26 '11 at 11:01

5 Answers5

6

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

Sajitha Rathnayake
  • 1,688
  • 3
  • 26
  • 47
2

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
dfrevert
  • 366
  • 5
  • 17
0

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
Adam
  • 147
  • 1
  • 13
0

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.

Community
  • 1
  • 1
Peter O.
  • 32,158
  • 14
  • 82
  • 96
  • Motherboard ID doesn't seem to be reliable. On my system, `wmic baseboard get serialnumber` returns an obviously bogus number. Though `wmic bios get serialnumber` *does* return a sensible-looking value on my laptop, i'd trust the underlying machine about as far as a peg-legged grasshopper could kick it. It could easily be a virtual machine set up with whatever IDs the creator and/or user feel like putting in. – cHao Sep 26 '11 at 03:38
  • Took back that the IDs are "reliable". – Peter O. Sep 26 '11 at 03:47
0

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

Community
  • 1
  • 1
Laszlo the Wiz
  • 554
  • 4
  • 14