我正在使用 Managed WiFi API 和示例代码:
string profileName = "Cheesecake"; // this is also the SSID
string mac = "52544131303235572D454137443638";
string key = "hello";
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><name>{0}</name></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);
wlanIface.SetProfile( Wlan.WlanProfileFlags.AllUser, profileXml, true );
wlanIface.Connect( Wlan.WlanConnectionMode.Profile, Wlan.Dot11BssType.Any, profileName );
我更新了代码以使用我的 SSID 和 key ,但我不知道如何获取 MAC 地址。
最佳答案
PhysicalAddress 类应该可以帮助您。 MSDN 文章中甚至有一个代码示例,它从机器上的网络接口(interface)中提取 MAC 地址。
http://msdn.microsoft.com/en-us/library/system.net.networkinformation.physicaladdress.aspx
希望这对您有所帮助。
关于c# - 在 C# 中连接到无线网络,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6318575/