using System;
using System.Collections.Generic;
using System.Text;
using System.Management;//System.Management.dll
namespace test_get_current_connect_console
{
class Program
{
static void Main(string[] args)
{
int i = 0;
ManagementObjectSearcher searcher = new ManagementObjectSearcher("root//WMI","SELECT * FROM MSNdis_80211_ServiceSetIdentifier where active = true");
try
{
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("MSNdis_80211_ServiceSetIdentifier instance");
Console.WriteLine("-----------------------------------");
if (queryObj["Ndis80211SsId"] == null)
Console.WriteLine("Ndis80211SsId: {0}", queryObj["Ndis80211SsId"]);
else
{
Byte[] arrNdis80211SsId = (Byte[])(queryObj["Ndis80211SsId"]);
Console.Write("Ndis80211SsId:");
foreach (Byte arrValue in arrNdis80211SsId)
{
if (i++ > 3)
{
if (arrValue > 0)
{
Console.Write("{0}", (char)arrValue);
}
}
}
Console.WriteLine("");
break;
}
}//end fereach
Console.ReadLine();
}
catch
{
Console.WriteLine("Error");
Console.ReadLine();
}
}// end Main
}//end class Program
}
参考:http://www.metageek.net/svn/Inssider/trunk/WmiWirelessInterface.cs<br /> http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/02e193f7-3f07-4c5c-9968-ac25ea96622b/