(C#)如何检测监视器状态 [英] (c#) how to detect the monitor status
问题描述
我有一个控制台应用程序.
导入Dll以获取监视器状态.
例如显示器关闭或显示器打开.
我使用受保护的覆盖无效WndProc(ref System.Windows.Forms.Message m)"
dll项目中的方法,
当然,我必须在winForm下使用"WndProc"方法.
因此,当我的程序运行时,它将显示一个winForm和一个控制台窗口.
当焦点不在winForm上时,它似乎没有用.
我认为当焦点不在winForm上时,"WndProc"无效.
如何在Dll中获取显示器状态?
任何帮助将不胜感激.
I have a console application.
Import a Dll to get the monitor status.
such as the monitor is off or monitor is on.
i use the "protected override void WndProc(ref System.Windows.Forms.Message m)"
mothod in the dll project,
of course i have to use the "WndProc" method under a winForm.
So when my program is running, it will display a winForm and a console window.
it seem to no useful when the focus is not on the winForm.
i think that the "WndProc"is invalid when the focus is not on the winForm.
How can i get the monitor status in the Dll?
any help will be appreciated.
推荐答案
您可以使用WMI ^ ]包含对您有用的任何内容.
You can look at using WMI[^] contains anything useful for you.
这篇关于(C#)如何检测监视器状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!