如何在控制台应用程序中获取屏幕分辨率(如果可能)?
而在Forms
我可以用:
int height = Screen.PrimaryScreen.Bounds.Height;
int width = Screen.PrimaryScreen.Bounds.Width;
但我正在寻找专门的控制台方式。
所以解决我的问题的方法是由马克·安托万·尤特拉斯 https://stackoverflow.com/users/7931456/marc-antoine-jutras。我需要int
价值观所以我是这样的:
int height = Convert.ToInt32(SystemParameters.PrimaryScreenHeight);
int width = Convert.ToInt32(SystemParameters.PrimaryScreenWidth);
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"]);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)