2011-11-01 21 views
0

以下代碼在Win XP中正常工作直到確定WLAN卡,但在Windows 7中,wmiObjects數爲零。如何在Windows 7中查找WLAN卡

有沒有人有任何知識讓它在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); 
} 

回答

0

MSDis802_11_Configuration使用管理API僅在WinXP和Win2003的支持。

請嘗試使用Win32_NetworkAdapter。