0

我需要一个返回字符串的函数,使用硬件序列号并将它们混合在一起以获得单个序列号。

我搜索了尝试这样的功能,但找不到类似的功能,此功能需要识别具有许可系统的电脑。

我只需要每台计算机相同的值。

4

1 回答 1

1

这可能不是您想要的,但如果我正确理解您的问题,请使用下面的代码(不要在 Strict On 的情况下使用下面的代码)不是最好的想法,但它可以工作......

Private Function SystemSerialNumber() As String
    ' Get the Windows Management Instrumentation object.
    Dim wmi As Object = GetObject("WinMgmts:")

    ' Get the "base boards" (mother boards).
    Dim serial_numbers As String = ""
    Dim mother_boards As Object = _
        wmi.InstancesOf("Win32_BaseBoard")
    For Each board As Object In mother_boards
        serial_numbers &= ", " & board.SerialNumber
    Next board
    If serial_numbers.Length > 0 Then serial_numbers = _
        serial_numbers.Substring(2)

    Return serial_numbers
End Function

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

来源: http ://www.vb-helper.com/howto_net_get_cpu_serial_number_id.html

于 2012-07-18T22:54:58.533 回答