当前位置 : 主页 > 编程语言 > c语言 >

vb.net – 如何获得PC唯一ID?

来源:互联网 收集:自由互联 发布时间:2021-06-24
什么是PC唯一ID? 我们怎样才能获得PC unqiue ID? 是关于硬盘还是主板? 我想在我的窗口程序中存储PC ID.请分享我 这对我有用 Private Function CpuId() As String Dim computer As String = "." Dim wmi As
>什么是PC唯一ID?
>我们怎样才能获得PC unqiue ID?
>是关于硬盘还是主板?

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

这对我有用

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

见here

网友评论