且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何以编程方式连接到 Windows 10 中的隐藏 SSID?

更新时间:2023-01-02 08:53:31

如果可用,隐藏网络应该在 firstAdapter.NetworkReport.AvailableNetworks 列表中.

由于 SSID 被隐藏,目标网络的 WiFiAvailableNetworkSsid 属性将为 "".

您可以在此处进行假设并尝试使用以下方法连接到它:

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

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

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");