question

ansalc-1556 avatar image
0 Votes"
ansalc-1556 asked ·

How to detect if wireless or wired ethernet

In an UWP, how can I detect if my laptop is connected to the internet via Wifi or via wired ethernet?

Thanks.

windows-uwp
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

yanxiaodi avatar image
0 Votes"
yanxiaodi answered ·

You can use ConnectionProfile in Windows.Networking.Connectivity.

IsWlanConnectionProfile
Gets a value that indicates if connection profile is a WLAN (WiFi) connection. This determines whether or not WlanConnectionProfileDetails is null.

IsWwanConnectionProfile
Gets a value that indicates if connection profile is a WWAN (mobile) connection. This determines whether or not WwanConnectionProfileDetails is null.

FYI: https://docs.microsoft.com/en-us/uwp/api/windows.networking.connectivity.connectionprofile?view=winrt-18362
Thanks.

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you!

This is what worked for me:

var InternetConnectionProfile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
bool isWLANConnection = InternetConnectionProfile.IsWlanConnectionProfile;

0 Votes 0 ·