首页 > 解决方案 > 使用winmgmts读取我电脑的mac地址

问题描述

我有以下代码

object objectValue1 = RuntimeHelpers.GetObjectValue(NewLateBinding.LateGet(RuntimeHelpers.GetObjectValue(Interaction.GetObject("winmgmts:\\\\.\\root\\cimv2", (string) null)), (Type) null, "ExecQuery", new object[1]
    {
      (object) "Select * from WIN32_NetworkAdapterConfiguration"
    }, (string[]) null, (Type[]) null, (bool[]) null));
    try
    {
      foreach (object obj in (IEnumerable) objectValue1)
      {
        object objectValue2 = RuntimeHelpers.GetObjectValue(obj);
        string Left;
        try
        {
          Left = Conversions.ToString(NewLateBinding.LateGet(objectValue2, (Type) null, "MACAddress", new object[0], (string[]) null, (Type[]) null, (bool[]) null));
        }

我试图读出我的mac地址,但问题是我有时有3倍相同的mac地址,有时我的ras适配器的mac地址会改变。你能帮助我吗?

标签: c#adaptermac-address

解决方案


推荐阅读