Пример #1
0
        public static List <string> GetScreenResolutions()
        {
            var resolutions = new List <string>();

            try
            {
                var devMode = new DEVMODE();
                int i       = 0;

                while (EnumDisplaySettings(null, i, ref devMode))
                {
                    resolutions.Add(string.Format("{0}x{1}", devMode.dmPelsWidth, devMode.dmPelsHeight));
                    i++;
                }

                resolutions = resolutions.Distinct(StringComparer.InvariantCulture).ToList();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Could not get screen resolutions.");
            }

            return(resolutions);
        }
Пример #2
0
 private static extern bool EnumDisplaySettings(string lpszDeviceName, int iModeNum, ref DEVMODE lpDevMode);