using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace ShareWifi.Utils.Net
{
class WifiUtils
{
///
/// 获取WIFI SSID ,如果为空则没有连接wifi
///
///
public static string getSSID()
{
string cmdRes = Shell.RunCmd("netsh wlan show interfaces | findstr SSID");
Regex regex = new Regex("[^B]SSID\\s+:\\s(.*)");
return regex.Match(cmdRes).Groups[1].Value.Trim();
}
///
/// 根据 SSID 获取密码
///
/// SSID
///
public static string getSSDIPassword(string ssid)
{
string cmdRes = Shell.RunCmd("netsh wlan show profile name=" + ssid + " key=clear | findstr Key");
Regex regex = new Regex("Key Content\\s+:\\s(.*)");
return regex.Match(cmdRes).Groups[1].Value.Trim();
}
}
}