How to get "Active signal resolution"?

** 146 Reputation points
2021-03-31T18:26:45.637+00:00

83349-asr.png

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,389 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,100 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,484 questions
0 comments No comments
{count} votes

1 additional answer

Sort by: Most helpful
  1. Timon Yang-MSFT 9,571 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.