我正在使用C#开发.NET Framework的Windows应用程序。我想知道是否有任何计算机制造商都可以生产的唯一ID,无论由哪个制造商制造,但必须是唯一的。
谢谢, Bibhu
请查看:如何获取计算机的唯一ID
硬盘ID(卷序列号)
查找唯一的卷序列号与查找唯一设备ID非常相似,但幸运的是要简单一些:
ManagementObject dsk = new ManagementObject(@"win32_logicaldisk.deviceid=""" + drive + @":""");
dsk.Get();
string volumeSerial = dsk["VolumeSerialNumber"].ToString();
如果是Windows应用程序,您可以获取MAC地址,这将是唯一的。
如果它们都在同一个Windows网络中,请使用计算机名称。是的,有时它们可能具有相同的名称,但为了访问每台计算机,网络将为每个计算机分配唯一的名称。
您可以使用主板序列号:
public static string GetMBSN()
{
//Getting list of motherboards
ManagementObjectCollection mbCol = new ManagementClass("Win32_BaseBoard").GetInstances();
//Enumerating the list
ManagementObjectCollection.ManagementObjectEnumerator mbEnum = mbCol.GetEnumerator();
//Move the cursor to the first element of the list (and most probably the only one)
mbEnum.MoveNext();
//Getting the serial number of that specific motherboard
return ((ManagementObject)(mbEnum.Current)).Properties["SerialNumber"].Value.ToString();
}