C# 控制台应用中获取屏幕分辨率
引用System.Management安装包。
using System.Management; ManagementObjectSearcher mydisplayResolution = new ManagementObjectSearcher("SELECT CurrentHorizontalResolution, CurrentVerticalResolution FROM Win32_VideoController"); foreach (ManagementObject record in mydisplayResolution.Get()) { Console.WriteLine("-----------------------Current Resolution---------------------------------"); Console.WriteLine("CurrentHorizontalResolution - " + record["CurrentHorizontalResolution"]); Console.WriteLine("CurrentVerticalResolution - " + record["CurrentVerticalResolution"]); }