How do I connect to a hidden SSID in Windows 10 programmatically?

喜你入骨 提交于 2021-02-05 08:13:28

问题


I have spent ages on this and I am stuck.
I am trying to connect to a known hidden SSID programmatically.

I am using the following code

await firstAdapter.ScanAsync();

WiFiAvailableNetwork network = firstAdapter.NetworkReport.AvailableNetworks.FirstOrDefault(n => n.Ssid == ssid);

The problem is I need to supply as a first an object of type WiFiAvailableNetwork but AvailableNetworks only brings back non-hidden SSIDs.

public IAsyncOperation<WiFiConnectionResult> ConnectAsync(WiFiAvailableNetwork availableNetwork, WiFiReconnectionKind reconnectionKind, PasswordCredential passwordCredential, String ssid)

https://docs.microsoft.com/en-us/uwp/api/windows.devices.wifi.wifiadapter.connectasync#Windows_Devices_WiFi_WiFiAdapter_ConnectAsync_Windows_Devices_WiFi_WiFiAvailableNetwork_Windows_Devices_WiFi_WiFiReconnectionKind_Windows_Security_Credentials_PasswordCredential_System_String_

The above code works perfectly with non-hidden SSID's.
Is there an API to connect to a hidden SSID?
Thanks


回答1:


If available, the hidden network should be in the firstAdapter.NetworkReport.AvailableNetworks list.

As the SSID is hidden, the Ssid property of WiFiAvailableNetwork for the target network will be "".

You could make an assumption here and attempt to connect to it using:

await firstAdapter.ConnectAsync(networks.First(x => x.Ssid == ""), WiFiReconnectionKind.Automatic, "password", "knownSSID");



来源:https://stackoverflow.com/questions/50823511/how-do-i-connect-to-a-hidden-ssid-in-windows-10-programmatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!