我正在使用 C# 在 .NET Framework 中开发 Windows 应用程序。我想知道制造的每台计算机是否有任何唯一 ID,让它由任何制造商制造,但它必须是唯一的。
谢谢,比布
检查这个:如何获取计算机的唯一 ID
硬盘驱动器 ID(卷序列号)
找到一个独特的卷系列的工作方式非常相似,幸运的是更简单:
ManagementObject dsk = new ManagementObject(@"win32_logicaldisk.deviceid=""" + drive + @":""");
dsk.Get();
string volumeSerial = dsk["VolumeSerialNumber"].ToString();
如果它是一个 Windows 应用程序,你可以获得 mac 地址。这将是独一无二的。
您可以使用主板序列号:
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();
}
如果它们都在同一个 windows 网络中,则使用计算机名称。是的,有时它们可能具有相同的名称,但要访问每台 PC,网络将为每台 PC 设置唯一的名称。