Answer the question
In order to leave comments, you need to log in
How to find out the correct screen resolution in C#?
I need to get the screen resolution for a screenshot, but when I try to get the resolution this way:
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size
Answer the question
In order to leave comments, you need to log in
AlexanderProkopenko ,
an example from
https://www.codeproject.com/Articles/6810/Dynamic-...
despite its venerable age
it works, you may have to upgrade the project (it's easy) from the author's code
as described in
https://www. pinvoke.net/default.aspx/user32.enumdi... :
[DllImport("user32.dll")]
public static extern int EnumDisplaySettings(string deviceName, int modeNum, ref DEVMODE1 devMode);
public struct DEVMODE1 {
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string dmDeviceName;
// детали
DEVMODE1 dm = new DEVMODE1();
User_32.EnumDisplaySettings(null, User_32.ENUM_CURRENT_SETTINGS, ref dm)) ;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question