我想知道是否可以使用託管的無線接入點連接到無線網絡?C#使用託管的無線接口連接到無線網絡
6
A
回答
7
基本上,是的。
也許你應該花幾分鐘搜索。從Managed Wifi API codeplex page:
庫使用的本地WiFi API,...
所以要本地WiFi API:MSDN
連接或斷開無線網絡。請參閱WlanConnect和WlanDisconnect。
,此外,在管理的無線上網API WlanApi.cs的源代碼:
/// <summary>
/// Requests a connection (association) to the specified wireless network.
/// </summary>
/// <remarks>
/// The method returns immediately. Progress is reported through the <see cref="WlanNotification"/> event.
/// </remarks>
public void Connect(Wlan.WlanConnectionMode connectionMode, Wlan.Dot11BssType bssType, string profile)
{
Wlan.WlanConnectionParameters connectionParams = new Wlan.WlanConnectionParameters();
connectionParams.wlanConnectionMode = connectionMode;
connectionParams.profile = profile;
connectionParams.dot11BssType = bssType;
connectionParams.flags = 0;
Connect(connectionParams);
}
和網站的獨特樣品是做什麼的! Sample
static void Main(string[] args)
{
WlanClient client = new WlanClient();
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)
{
Console.WriteLine("Found WEP network with SSID {0}.", GetStringForSSID(network.dot11Ssid));
}
}
// Retrieves XML configurations of existing profiles.
// This can assist you in constructing your own XML configuration
// (that is, it will give you an example to follow).
foreach (Wlan.WlanProfileInfo profileInfo in wlanIface.GetProfiles())
{
string name = profileInfo.profileName; // this is typically the network's SSID
string xml = wlanIface.GetProfileXml(profileInfo.profileName);
}
// Connects to a known network with WEP security
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);
}
}
祝您有美好的一天!
1
在Windows 10中有API可以執行此操作。
見WiFiAdapter class on MSDN和一些sample code on GitHub
我看到過的管理API的好處是,你不必應付創建一個XML配置文件連接到新的網絡。您實際上可以使用密碼連接到網絡。
相關問題
- 1. 連接到無線網絡
- 2. 連接到C#無線網絡
- 3. 配置有線和無線連接的網絡接口
- 4. 使用C#和Compact Framework管理無線網絡連接
- 5. 無線網絡已連接但未連接到網絡
- 6. 無法連接無線網絡連接套接字連接
- 7. vb.net wince連接到無線網絡
- 8. 使用VB.NET連接到可用的無線網絡
- 9. (C,Linux)知道網絡接口是無線還是有線
- 10. 用於Win7託管的QEMU Debian:無法連接到網絡
- 11. 檢測連接到無線網絡的手機 - C#
- 12. 從無線接入點讀取無線網絡屬性,無需連接
- 13. 無法使用網絡線程連接到Facebook
- 14. 使用網絡在本地無線連接到Apache Tomcat
- 15. 如何連接到無線網絡與c + +
- 16. 使用c連接到安全的無線連接#
- 17. 的Android如何讓網絡/無線網絡連接的IP
- 18. 連接無線/無線鍵盤到Android
- 19. 如何使用windows NETSH命令連接到隱藏的無線網絡(無SSID)?
- 20. 科爾多瓦 - 檢查無線網絡連接到互聯網
- 21. 如何檢查用戶是否連接到無線網絡?
- 22. 使用,無需連接到網絡
- 23. 在有線網絡中使用stlplus庫連接,並且在無線連接中不進行連接
- 24. 開始和等待無線網絡連接 - 線程
- 25. QT Webkit似乎無視新的無線網絡連接
- 26. 使用python從無線網絡斷開連接(Windows)中
- 27. scheduleInRunLoop - 線程網絡連接
- 28. Android連接到wifi熱點已經連接到其他無線網絡
- 29. 如何連接到android的無線網絡?
- 30. 命令行連接到無線網絡上的Ubuntu 10.04
感謝您的iot樣本鏈接。 – 2016-09-05 00:21:35