現在接続されているWifiネットワークのSSIDを取得する必要があるという同様の問題がありましたが、その複雑さのためにAPIのラッパーを作成する気がしなかったので、netshを使用しない理由を考えました
ProcessStartInfo info = new ProcessStartInfo("netsh", "wlan show interfaces");
info.WorkingDirectory = @"%WINDIR%\system32";
info.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
info.CreateNoWindow = true;
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = info;
proc.Start();
その後、proc.StandardOutput.ReadToEnd(); から出力を取得できます。文字列から必要なものを解析します。
"\r\n There is 1 interface on the system: \r\n\r\n
Name : Wireless Network Connection\r\n
Description : Atheros AR9285 Wireless Network Adapter\r\n
GUID : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\r\n
Physical address : xx:xx:xx:xx:xx:xx\r\n
State : connected\r\n
SSID : Dynex2\r\n
BSSID : xx:xx:xx:xx:xx:xx\r\n
Network type : Infrastructure\r\n
Radio type : 802.11g\r\n
Authentication : WPA2-Personal\r\n
Cipher : CCMP\r\n
Connection mode : Auto Connect\r\n
Channel : 1\r\n
Receive rate (Mbps) : 54\r\n
Transmit rate (Mbps) : 54\r\n
Signal : 100% \r\n
Profile : Dynex2 \r\n\r\n
Hosted network status : Not available\r\n\r\n"
API のラッパーを作成するよりも、文字列を解析する方がはるかに簡単です