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"]);

}

 

posted @ 2023-10-15 12:18  芈璐  阅读(151)  评论(0编辑  收藏  举报