Listing and connecting WiFi using WinRt

2019-07-22 04:14发布

问题:

In my office I have 10 WiFi routers.I want to list all those(similar to Network icon in the system tray on windows 8) and connect/disconnect to one of them through Win Rt.

I tried these API

 Windows::Networking::Connectivity::NetworkInformation::GetLanIdentifiers();
 Windows::Networking::Connectivity::NetworkInformation::GetConnectionProfiles();
 NetworkInformation::GetInternetConnectionProfile();

but these Api only list connected one, it doesn't list others

I can achieve this using http://msdn.microsoft.com/en-us/library/windows/desktop/ms706716(v=vs.85).aspx. But I am not sure this Api will be supported on Windows 8 metro mode.

Does WinRt provides Api support for this ??

回答1:

You cannot connect/disconnect to a network from a Windows App. You can only check informations. The reason is (for Microsoft) that the connection manager is accessible from your app through the charms bar.

This functionality is not exposed to Metro style applications. An operator's app can create profiles for their networks (with known SSIDs), but listing and connecting to visible networks is controlled by the user via the Windows connection management UI, not by an application. [Mike Bishop [MSFT], here]

The advanced connectivity functionnalities are present in Windows.Networking.NetworkOperators, which functionalities are only available to mobile operator apps and Windows Store apps given privileged access by mobile network operators.

Take a look at the Microsoft's Network information sample which shows what you can achieve with this API.