WlanClient.WlanInterface tempIFace = null; WlanClient client = new WlanClient(); foreach ( WlanClient.WlanInterface wlanIface in client.Interfaces ) { // Lists all available networks Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList( 0 ); foreach ( Wlan.WlanAvailableNetwork network in networks ) { if ( GetStringForSSID( network.dot11Ssid ).Equals( "test" ) ) { string profileName = GetStringForSSID( network.dot11Ssid ); var macAddress = ConvertToHex( GetStringForSSID( network.dot11Ssid ) ); string mac = macAddress; string key = "123456789a"; string profileXml = string.Format( "<?xml version=\"1.0\"?><WLANProfile xmlns=\"http://www.microsoft.com/networking/WLAN/profile/v1\"><name>{0}</name><SSIDConfig><SSID><hex>{1}</hex></SSID></SSIDConfig><connectionType>ESS</connectionType><MSM><security><authEncryption><authentication>open</authentication><encryption>WEP</encryption><useOneX>false</useOneX></authEncryption><sharedKey><keyType>networkKey</keyType><protected>false</protected><keyMaterial>{2}</keyMaterial></sharedKey><keyIndex>0</keyIndex></security></MSM></WLANProfile>", profileName, mac, key ); tempIFace = wlanIface; tempIFace.SetProfile( Wlan.WlanProfileFlags.AllUser, profileXml, true ); tempIFace.Connect( Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Any, GetStringForSSID( network.dot11Ssid ) ); MessageBox.Show( GetStringForSSID( network.dot11Ssid ) ); break; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)