C#如何连接wifi和指定IP


大家好哈,这是我第一次写博客,我也是才大一结束,自学了10多天C#,有不对的欢迎大家指正,最近因为项目的事而被Wifi和IP折磨了很久,后来借用了一下外国人的SimpleWifi.dll 再自己写了一个ZhuWifi.dll
能够直接通过Wifi名和密码来连接Wifi 在该类当中我还写了一个指定IP的函数。看看下面是怎么用的。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

//需要的引用:
using System.Diagnostics;
using System.ComponentModel;
using SimpleWifi;//在SimpleWifi.dll中
using SimpleWifi.Win32;//在Simple.dll中
using ZhuWifi;//在ZhuWifi.dll中

namespace Wifidemo
{
    //特别注意
    //需要把右边的manifest中的 <requestedExecutionLevel level="asInvoker" uiAccess="false" />
    //改为 <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
    //这样才能成功修改IP
    class Program
    {
        static void Main(string[] args)
        {
         
            string wifiName = "nanyuan"; ;
            string wifikey = "qwertyuiop";
            string IP = "192.168.1.47";
            //实例化
            WifiFun s = new WifiFun();
            Console.ReadKey();
            //用于连接wifi和指定IP
            bool flag1=s.ConnectEquipment(wifiName, wifikey, IP);
//只用于指定IP
bool flag2 = s.SetIP(IP);
wifiName = "2014011"; wifikey = "456789FAN"; Console.ReadKey(); //只用于连接wifi bool flag3= s.ConnectComputer(wifiName, wifikey); Console.ReadKey(); } } }
就是这样就可以连接Wifi,如果能够加上字典 就可以暴力破解WIFI啦。
注意了我类库里面的SetIP方法是调用DOS来修改IP的,你们要把程序代码写为以管理员身份运行,这个你们百度就行啦
那两个dll文件在我的云盘,链接:http://pan.baidu.com/s/1o67pmsy
希望大家以后能喜欢我的文章
原文地址:https://www.cnblogs.com/Huaran1chendu/p/4742244.html