コード例 #1
0
        static void SelectCurrentWifi(Wlan.WlanAvailableNetwork network, WlanClient.WlanInterface wlanIface)
        {
            string name = GetStringForSSID(network.dot11Ssid);
            string xml  = "";

            foreach (Wlan.WlanProfileInfo profileInfo in wlanIface.GetProfiles())
            {
                if (profileInfo.profileName == name) // this is typically the network's SSID
                {
                    xml = wlanIface.GetProfileXml(name);
                }
                else
                {
                    if (network.dot11DefaultCipherAlgorithm == Wlan.Dot11CipherAlgorithm.None)
                    {
                        SelectWifiWithNoKey(name, ref wlanIface);
                    }
                    else
                    {
                        Console.WriteLine("没有WiFiProfile信息,请先创建登录信息");
                    }

                    //Console.ReadKey();
                }
            }
        }
コード例 #2
0
        public string GetProfileXml(string profileName)
        {
            if (interFace == null)
            {
                return(string.Empty);
            }

            return(interFace.GetProfileXml(profileName));
        }
コード例 #3
0
ファイル: NetFi.cs プロジェクト: willnode/Network-Facts
        public void Arcquire()
        {
            Profiles.Clear();

            WlanClient client = new WlanClient();

            // Lists all networks with WEP security
            Wlan.WlanAvailableNetwork[] networks = iFace.GetAvailableNetworkList(0);

            var x = new System.Xml.Serialization.XmlSerializer(typeof(WLANProfile));

            // Retrieves XML configurations of existing profiles.
            // This can assist you in constructing your own XML configuration
            foreach (Wlan.WlanProfileInfo profileInfo in iFace.GetProfiles())
            {
                string name = profileInfo.profileName; // this is typically the network's SSID

                string xml = iFace.GetProfileXml(name);

                using (TextReader reader = new StringReader(xml))
                {
                    var prov = x.Deserialize(reader) as WLANProfile;
                    Profiles.Add(new FiProfile(prov));
                }
            }

            foreach (var net in networks)
            {
                var ssid = net.dot11Ssid.ToStringBeauty();
                if (string.IsNullOrEmpty(ssid))
                {
                    continue;
                }
                var prof = Profiles.Where((p) => p.SSID == ssid).FirstOrDefault();
                if (prof != null)
                {
                    prof.SetAvailability(net);
                }
                else
                {
                    prof = new FiProfile(null);
                    prof.SetAvailability(net);
                    Profiles.Add(prof);
                }
            }

            Profiles.Sort(new FiProfileSorter());
        }
コード例 #4
0
        /// <summary>
        /// Retrieves XML configurations of existing profiles.
        /// This can assist you in constructing your own XML configuration (that is, it will give you an example to follow).
        /// </summary>
        /// <param name="wlanIface"></param>
        /// <returns></returns>
        public static string GetWlanProfileXml(WlanClient.WlanInterface wlanIface)
        {
            StringBuilder profileXml = new StringBuilder();

            Wlan.WlanProfileInfo[] profiles = wlanIface.GetProfiles();
            foreach (Wlan.WlanProfileInfo profileInfo in profiles)
            {
                // This is typically the network's SSID.
                string name = profileInfo.profileName;
                string xml  = wlanIface.GetProfileXml(name);
                Debug.WriteLine(string.Format("Found Wifi profile for SSID {0}.", name));
                Debug.WriteLine(string.Format("Wifi profile xml {0}.", xml));
                profileXml.AppendLine(xml);
            }

            return(profileXml.ToString());
        }
コード例 #5
0
 void UpdateData()
 {
     if (profiles.Length > 0)
     {
         if (cb_select_profile.SelectedIndex > profiles.Length - 1)
         {
             cb_select_profile.SelectedIndex = 0;
         }
         else
         {
             profile.LoadXml(adapter.GetProfileXml(profiles[cb_select_profile.SelectedIndex]));
             tb_preview.Text = profile.InnerXml;
             PharseProfile();
         }
     }
     else
     {
         Close();
     }
 }
コード例 #6
0
 public string GetProfileXml(string profileName)
 {
     return(_wlanInterface.GetProfileXml(profileName));
 }