Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get PC unique 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.

like image 981
soclose Avatar asked Sep 26 '11 03:09

soclose


1 Answers

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

like image 99
Sajitha Rathnayake Avatar answered Sep 27 '22 22:09

Sajitha Rathnayake