C#:ManagedWiFi问题 [英] C#: Problem with ManagedWiFi

查看:269
本文介绍了C#:ManagedWiFi问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在使用ManagedWiFi库。我希望通过SSID连接到特殊网络。连接的所有步骤都在代码中。我找到了很多样本​​并创建了一个很小的代码:



Hi every one,

I'm working with ManagedWiFi library. My hope is connecting to special network by SSID. All of step to connecting are in code. I found many sample and create a tiny code that:

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;
                    }  





这段代码运行得很好。但无法连接到这个wifi。



请告诉我有什么问题?以及如何修复它。

谢谢。



this code run very fine. but cannot connect to this wifi.

Please tell me what is problem? and how to fix it.
Thanks.

推荐答案

检查这里有一个API

http://managedwifi.codeplex.com/ [ ^ ]
check here there is a API
http://managedwifi.codeplex.com/[^]


这篇关于C#:ManagedWiFi问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆