我的WinForms应用程序如何获取用户的MachineID或ProcessorID?

时间:2009-02-18 05:24:33

标签: vb.net winforms

我正在寻找一种使用VB.net WinForms应用程序检索用户的MachineID或ProcessorID的方法?有什么想法吗?

2 个答案:

答案 0 :(得分:1)

另一种选择是获取系统中某个网卡的MAC地址。这是一个唯一的编号。下面的例程获取第一个网卡的mac地址,然后将地址中的字节附加到一个唯一的ulong中(抱歉是C#而不是VB.NET):


using System.Net.NetworkInformation;
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
if (nics.Length != 0)
{
    byte[] addressBytes = nics[0].GetPhysicalAddress().GetAddressBytes();
    if (addressBytes.Length > 6)
        throw new ApplicationException("Unexpected length for MAC address");

    ulong address = 0;
    foreach (byte b in addressBytes)
    {
        address 

答案 1 :(得分:0)

您可以使用WMI访问该信息。

string s = "SELECT SerialNumber FROM WIN32_BaseBoard";
System.Management.ManagementObjectSearcher oWMI = new
System.Management.ManagementObjectSearcher(s);
System.Management.ManagementObjectCollection oSerialNumbers = oWMI.Get();

foreach (System.Management.ManagementObject mo in oSerialNumbers)
{
Console.WriteLine("Serial Number: " +
mo.Properties["SerialNumber"].Value.ToString());
}

从这里引用: http://bytes.com/groups/net/411975-how-can-i-get-processor-id-my-computer

获取处理器ID的另一个示例如下: http://www.devasp.net/net/articles/display/149.html