problem with connection

Aug 3, 2009 at 6:56 AM

Hello , nice job

i try to search for a wireless network and it works.

But if i want to make a connection it don't works.

Maybe there's an error .

Please help me.

I show you the code........

 

WlanClient client = new WlanClient();
            
            String SSID="";
            String xmlProfile="";
            Wlan.WlanAvailableNetwork _netWork;
            try
            {
                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.dot11DefaultCipherAlgorithm == Wlan.Dot11CipherAlgorithm.WEP)
                        {
                            xmlProfile = wlanIface.GetProfileXml("RTA1025W-EA7D68");
                        }
                    }

                    string hexssid, _xmlprofile;
                    SSID = "BBWire.net";
                    string hexOutput = String.Format("{0:X}", SSID);

                    hexssid = hexOutput;
                    String key = "unirfq128bit!";

                    _xmlprofile = xmlProfile.Replace("{SSID}", SSID);
                    _xmlprofile = xmlProfile.Replace("{SSIDHEX}", hexssid);
                    _xmlprofile = xmlProfile.Replace("{KEY}", key);
                    
                    wlanIface.SetProfile(Wlan.WlanProfileFlags.AllUser, _xmlprofile, true);
                    wlanIface.Connect(Wlan.WlanConnectionMode.Auto, Wlan.Dot11BssType.Any, SSID);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }WlanClient client = new WlanClient();
            
            String SSID="";
            String xmlProfile="";
            Wlan.WlanAvailableNetwork _netWork;
            try
            {
                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.dot11DefaultCipherAlgorithm == Wlan.Dot11CipherAlgorithm.WEP)
                        {
                            xmlProfile = wlanIface.GetProfileXml("RTA1025W-EA7D68");
                        }
                    }

                    string hexssid, _xmlprofile;
                    SSID = "BBWire.net";
                    string hexOutput = String.Format("{0:X}", SSID);

                    hexssid = hexOutput;
                    String key = "myKey!";

                    _xmlprofile = xmlProfile.Replace("{SSID}", SSID);
                    _xmlprofile = xmlProfile.Replace("{SSIDHEX}", hexssid);
                    _xmlprofile = xmlProfile.Replace("{KEY}", key);
                    
                    wlanIface.SetProfile(Wlan.WlanProfileFlags.AllUser, _xmlprofile, true);
                    wlanIface.Connect(Wlan.WlanConnectionMode.Auto, Wlan.Dot11BssType.Any, SSID);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }