admin管理员组文章数量:1627760
1.WIFI 无线网卡可以使用控制台命令行控制,其命令如下:
# nest wlan disconnect //断开连接
# nest waln connect ssid="wifi_name" name="wifi_name" //连接wifi
public static void coniont(string cmd)
{
ProcessStartInfo startInfo = new ProcessStartInfo("cmd")
{
Verb = "runas",
UseShellExecute = false,
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
Process cmdProcess = new Process()
{
StartInfo = startInfo
};
cmdProcess.Start();
cmdProcess.StandardInput.WriteLine(cmd);
cmdProcess.StandardInput.Flush();
cmdProcess.StandardInput.Close();
string output = cmdProcess.StandardOutput.ReadToEnd();
cmdProcess.WaitForExit();
Console.WriteLine(output);
//cmdProcess.Close();
}
C# 控制块代码奉上;
在上述命令行中 连接WiFi仅适用于网卡已经有过连接的路由 经博主翻阅巨量信息发现控制命令无法连接未连接过的命令;
2.代码控制Wifi 模块SimpleWIFI.DLL 下载
1.NuGet2.GitHub:https://github/DigiExam/simplewifi
3.引入类库调用方法
Wifi getwifi = new Wifi();//实例化
getwifi.ConnectionStatusChanged += Getwifi_ConnectionStatusChanged;//添加连接状态事件
var wifi = getwifi.GetAccessPoints();//获取目前的所有连接状态
foreach (var point in wifi) //遍历wifi
{
if (point.Name.Equals("你的wifi名称"))//判断是否是需要的wifi名
{
Console.WriteLine("发现wifi:"+point.Name);
AuthRequest AR = new AuthRequest(point);
AR.Password = "你的WiFi密码";//创建wifi密码
point.Connect(AR);//连接
}
}
Console.Read();
博主建议从 Githut 下载引用,否则会报错,原因大多是在连接陌生网络时,微软需要查询配置档,但是从 NutGet 下载的插件并不能写入,但是 Githut 就可以;
版权声明:本文标题:C# Wifi 控制器 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1729001951a1182673.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论