0

下面的代码在 Win XP 中工作正常,直到确定 WLAN 卡,但在 Windows 7 中 wmiObjects 计数为零。

有没有人知道让它在 Windows 7 中工作?

//Use MSDis802_11_Configuration to determine if this nic is in the list of wlan cards

try
{
  ObjectQuery query = new ObjectQuery("SELECT * FROM MSNdis_80211_Configuration");
  ManagementObjectCollection wmiObjects = new ManagementObjectSearcher(new ManagementScope(@"\\.\root\wmi"), query).Get();

  //Go through the result, if an instance matches this card, determine that it is wireless
  foreach (ManagementObject obj in wmiObjects)
  {
    string instanceName = obj.GetPropertyValue("InstanceName") as String;

    if (String.Compare(instanceName, _name) == 0)
    {
      isWireless = true;
      break;
    }
  }

  Log.DoLog("Items found: " + wmiObjects.Count);
}
4

2 回答 2

0

您可以在 codeplex http://managedwifi.codeplex.com/上使用托管 api

于 2011-11-01T07:52:35.090 回答
0

MSDis802_11_Configuration 仅在 WinXP 和 Win2003 中受支持。

尝试改用 Win32_NetworkAdapter。

于 2013-11-16T01:16:50.043 回答