【问题标题】:WMI reports non-unique processor id, hard drive id and mac addressWMI 报告非唯一的处理器 ID、硬盘驱动器 ID 和 MAC 地址
【发布时间】:2012-03-23 02:23:12
【问题描述】:

我们有以下代码来检索硬盘 id 处理器 id 和 mac 地址:

    private static string GetWMIValue(string query, string propertyName)
{
  try
  {
    using (ManagementObjectSearcher search = new ManagementObjectSearcher(query))
    {
      using (ManagementObjectCollection results = search.Get())
      {
        foreach (var result in results)
        {
          if (result != null && result[propertyName] != null)
          {
            return result[propertyName].ToString();
          }
        }
      }
    }
  }
  catch
  {
    // do nothing.
  }

  return null;
}

public static string GetHardDriveSerialNumber()
{
  string driveLetterName = Assembly.GetExecutingAssembly().Location.Substring(0, 1);
  return GetWMIValue("SELECT VolumeSerialNumber FROM Win32_LogicalDisk WHERE DeviceID=\"" + driveLetterName + ":\"", "VolumeSerialNumber");
}

public static string GetProcessorId()
{
  return GetWMIValue("SELECT ProcessorId FROM Win32_Processor", "ProcessorId");
}

public static string GetMacAddress()
{
  return GetWMIValue("SELECT MacAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "MacAddress");
}

除了在一个特定品牌的平板电脑上(据我们所知)外,​​它运行良好。在这个品牌上,每台机器都有相同的 3 个值。您可以想象,这在一定程度上影响了我们的许可。

有没有人见过这个或者有没有更好更可靠的机制?

谢谢

【问题讨论】:

  • 尝试将Win32_DiskDrive WMI 类的SerialNumberSignature 值添加到您的公式中。

标签: c# wmi


【解决方案1】:

经过更多研究,这似乎是一个众所周知和谈论的问题。我需要做一些工作......

谢天谢地,这不是我的烂摊子 :) 我只需要修复它 :(

【讨论】:

    猜你喜欢
    • 2012-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-04
    • 2018-01-26
    • 1970-01-01
    • 2011-08-06
    相关资源
    最近更新 更多