最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

c#使用ManagedWifi查看當(dāng)前Wifi信號并選擇wifi的示例

 更新時(shí)間:2014年04月09日 10:01:06   作者:  
這篇文章主要介紹了c#使用ManagedWifi查看當(dāng)前Wifi信號并選擇wifi的示例,需要的朋友可以參考下

使用ManagedWifi查看當(dāng)前Wifi信號并選擇wifi

復(fù)制代碼 代碼如下:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NativeWifi;

namespace WifiExample
{
    class WifiManager
    {
        //CMCC的WIFISSID
        public WIFISSID cmccWifiSSID;

        public WifiManager()
        {
            ScanSSID();
        }

        /// <summary>
        /// 將SSID轉(zhuǎn)化成字符串
        /// </summary>
        static string GetStringForSSID(Wlan.Dot11Ssid ssid)
        {
            return Encoding.UTF8.GetString(ssid.SSID, 0, (int)ssid.SSIDLength);
        }

        /// <summary> 
        /// 枚舉所有無線設(shè)備接收到的SSID 
        /// </summary> 
        public void ScanSSID()
        {
            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)
                {
                    WIFISSID targetSSID = new WIFISSID();
                    targetSSID.wlanInterface = wlanIface;
                    targetSSID.wlanSignalQuality = (int)network.wlanSignalQuality;
                    targetSSID.SSID = GetStringForSSID(network.dot11Ssid);
                    targetSSID.dot11DefaultAuthAlgorithm = network.dot11DefaultAuthAlgorithm.ToString();
                    targetSSID.dot11DefaultCipherAlgorithm = network.dot11DefaultCipherAlgorithm.ToString();
                    Console.WriteLine(targetSSID.SSID);
                    if (targetSSID.SSID.ToLower().Equals("cmcc"))
                    {
                        cmccWifiSSID = targetSSID;
                        return;
                    }
                }
            }
        } // EnumSSID 

        /// <summary> 
        /// 連接到CMCC
        /// </summary> 
        /// <param name="ssid"></param> 
        public void ConnectToCMCC()
        {
            // Connects to a known network with WEP security 
            string profileName = cmccWifiSSID.SSID; // this is also the SSID
            Console.WriteLine("profileName" + profileName);
            cmccWifiSSID.wlanInterface.Connect(Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Any, profileName);
        }

        /// <summary> 
        /// 字符串轉(zhuǎn)Hex 
        /// </summary> 
        /// <param name="str"></param> 
        /// <returns></returns> 
        public static string StringToHex(string str)
        {
            StringBuilder sb = new StringBuilder();
            byte[] byStr = System.Text.Encoding.Default.GetBytes(str); //默認(rèn)是System.Text.Encoding.Default.GetBytes(str) 
            for (int i = 0; i < byStr.Length; i++)
            {
                sb.Append(Convert.ToString(byStr[i], 16));
            }

            return (sb.ToString().ToUpper());
        }

    } // Class WifiManager


    class WIFISSID
    {
        public string SSID = "NONE";
        public string dot11DefaultAuthAlgorithm = "";
        public string dot11DefaultCipherAlgorithm = "";
        public bool networkConnectable = true;
        public string wlanNotConnectableReason = "";
        public int wlanSignalQuality = 0;
        public WlanClient.WlanInterface wlanInterface = null;
    }

}
```


調(diào)用鏈接CMCC
===
```
WifiManager wm = new WifiManager();
wm.ConnectToCMCC();

相關(guān)文章

最新評論

龙川县| 玉树县| 巩留县| 达孜县| 始兴县| 通江县| 边坝县| 阿拉善盟| 陕西省| 北流市| 富平县| 海淀区| 榆中县| 民丰县| 韩城市| 浦县| 独山县| 赫章县| 肥西县| 浑源县| 冷水江市| 花垣县| 满洲里市| 广河县| 宿迁市| 伽师县| 孝昌县| 阿瓦提县| 老河口市| 满洲里市| 盐亭县| 峨边| 华安县| 应用必备| 封丘县| 湟源县| 莲花县| 日喀则市| 鄂托克旗| 东阿县| 酉阳|