How to Find WLAN card in Windows 7

571 views Asked by At

The below code works fine in Win XP til determine the WLAN Card, but in Windows 7 the wmiObjects count is zero.

Does anyone have any knowledge to get it working in 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);
}
2

There are 2 answers

0
Mustafa Ekici On BEST ANSWER

you can use managed api on codeplex http://managedwifi.codeplex.com/

0
Sevenfold On

MSDis802_11_Configuration is only supported in WinXP and Win2003.

Try using Win32_NetworkAdapter instead.