C# 如何在Windows 7中查找WLAN卡
以下代码在Win XP中正常工作,直到确定WLAN卡,但在Windows 7中wmiObjects计数为零 有人知道如何让它在Windows7中工作吗C# 如何在Windows 7中查找WLAN卡,c#,.net,console-application,objectquery,C#,.net,Console Application,Objectquery,以下代码在Win XP中正常工作,直到确定WLAN卡,但在Windows 7中wmiObjects计数为零 有人知道如何让它在Windows7中工作吗 //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")
//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);
}
您可以在codeplex上使用托管api。MSDis802\u 11\u配置仅在WinXP和Win2003中受支持 尝试改用Win32_NetworkAdapter