检查显示器是否已连接

我要制作一个简单的程序,向服务器报告监视器的状态(是开/关还是仅仅是连接)。 到目前为止,我正在使用我在另一个讨论中找到的这种方法,但它每次都只返回给我,即使我已断开我的显示器。

public static Boolean isMonitorActive() { Boolean active = false; var query = "select * from WmiMonitorBasicDisplayParams"; using (var wmiSearcher = new ManagementObjectSearcher("\\root\\wmi", query)) { var results = wmiSearcher.Get(); foreach (ManagementObject wmiObj in results) { // get the "Active" property and cast to a boolean, which should // tell us if the display is active. I've interpreted this to mean "on" active = (Boolean)wmiObj["Active"]; return active; } } return active; } 

我要每隔2-3分钟检查一次监视器的状态,所以我需要在System中使用与MonitorCout变量不同的东西,因为它已经初始化并且从程序的开头到结尾保持不变(如果我是没错。) 感谢阅读和帮助。