Rafael Rivera

Programmatically determining if your UWP app can use WLAN data in China

(revised )

Windows 11 Settings window showing Wi-Fi > WLAN data section

To comply with telecommunications regulations in China, all supported desktop editions of Windows include controls to manage which UWP apps have access to WLAN (e.g. Wi-Fi) data. Unfortunately, these controls don't appear in all installations of Windows. Instead, they only show up if Windows has been configured with a China-specific privacy access policy. In other words, on machines sold and operated in China and its territories.

To enable this policy manually, navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess and create or set ActivePolicyCode (REG_SZ) to zh. A reboot is required for this policy to take full effect.

App developers looking to detect if their app has WLAN data access—presumably to re-negotiate with the user—can do so by checking for the undocumented wifiData capability.

switch (AppCapability.Create("wifiData").CheckAccess())
{
case AppCapabilityAccessStatus.DeniedByUser:
case AppCapabilityAccessStatus.DeniedBySystem:
// Do something
break;
}

Note: The WLAN data controls do nothing if the PC doesn't also have cellular radio hardware installed. (It doesn't need to be connected to anything.) This will manifest as CheckAccess returning Allowed (and the app having WLAN data access) regardless of the toggle switch value.