问题
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