コード例 #1
0
        /// <summary>
        /// 连接到指定Wifi网络
        /// </summary>
        /// <param name="name">wifi名称</param>
        /// <param name="key">wifi密码</param>
        /// <returns></returns>
        public bool Connect(string name, string key)
        {
            WlanClient client = new WlanClient();

            foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
            {
                // Lists all networks with WEP security
                Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList(0);
                foreach (Wlan.WlanAvailableNetwork network in networks)
                {
                    if (network.profileName == name)
                    {
                        Connect(wlanIface, network, key);
                    }
                }

                if (wlanIface.InterfaceState == Wlan.WlanInterfaceState.Connected &&
                    wlanIface.CurrentConnection.isState == Wlan.WlanInterfaceState.Connected &&
                    wlanIface.CurrentConnection.profileName == name)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #2
0
        /// <summary>
        /// 是否连接到某wifi
        /// </summary>
        /// <param name="name">wifi名称</param>
        /// <returns></returns>
        public bool IsConnect(string name)
        {
            WlanClient client = new WlanClient();

            foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
            {
                if (wlanIface.InterfaceState == Wlan.WlanInterfaceState.Connected &&
                    wlanIface.CurrentConnection.isState == Wlan.WlanInterfaceState.Connected &&
                    wlanIface.CurrentConnection.profileName == name)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #3
0
 internal WlanInterface(WlanClient client, Wlan.WlanInterfaceInfo info)
 {
     this.client = client;
     this.info   = info;
 }