Found the answer. DISPLAYCONFIG_VIDEO_SIGNAL_INFO::activeSize
Accepted answer
1 additional answer
Sort by: Most helpful
-
Timon Yang-MSFT 9,576 Reputation points
2021-04-01T02:54:11.547+00:00 Please try the following code:
private async Task<string> GetActiveSignalResolution() { var all = await DeviceInformation.FindAllAsync(DisplayMonitor.GetDeviceSelector()); if (all != null) { foreach (var info in all) { if (info.Kind == DeviceInformationKind.DeviceInterface) { var display = await DisplayMonitor.FromInterfaceIdAsync(info.Id); if (display != null) { var size = display.NativeResolutionInRawPixels; return size.Width.ToString() + " × " + size.Height.ToString(); } } } } throw new NotSupportedException(); }
The code comes from this thread and it works for me after testing.
Because this code uses the UWP API, you need to install a nuget package: Microsoft.Windows.SDK.Contracts
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.