0

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);
}
Mustafa Ekici
  • 7,263
  • 9
  • 55
  • 75
Millerbean
  • 295
  • 2
  • 8
  • 17

2 Answers2

0

MSDis802_11_Configuration is only supported in WinXP and Win2003.

Try using Win32_NetworkAdapter instead.

0

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

Mustafa Ekici
  • 7,263
  • 9
  • 55
  • 75