need help,about connect Wireless!!!!

Last post 05-06-2008 22:51 by phlywsy. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 05-06-2008 22:51

    need help,about connect Wireless!!!!

     i'm write that code by c#,hope connect the wireless(CISCO AIR AP-1231G-K9)

    config the ap info:ptc001(ssid),Open Authentication(no addition)

     

    void connectWireless()
            {
                NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
                WirelessZeroConfigNetworkInterface wzcInterface = null;
                foreach (NetworkInterface ni in interfaces)
                {
                    if (!(ni is WirelessZeroConfigNetworkInterface)) continue;
                    wzcInterface = ni as WirelessZeroConfigNetworkInterface;
                    byte[] key = null;
                    bool b = wzcInterface.AddPreferredNetwork("ptc001", true, key, 1, AuthenticationMode.Open,
                            WEPStatus.WEPDisabled, null);
                    if (b)
                    {
                        try
                        {

                            for (int i = 0; i < wzcInterface.PreferredAccessPoints.Count; i++)
                            {
                                string apName = wzcInterface.PreferredAccessPoints[i].Name;
                                if (apName.Equals("ptc001"))
                                {
                                    if (!wzcInterface.AssociatedAccessPoint.Equals(apName))
                                    {                                    ;
                                        b = wzcInterface.ConnectToPreferredNetwork(apName);
                                    }
                                }

                            }
                        }
                        catch (Exception ee)
                        {
                            MessageBox.Show(ee.Message);
                        }
                    }
                  
                }
            }

     

    didn't work!!

     

Page 1 of 1 (1 items)