捕获屏幕保护程序事件的问题

时间:2013-06-10 09:13:44

标签: c#

我正在尝试捕获屏幕保护程序事件,但是当我运行我的应用程序并进行个性化>屏幕保护程序>预览并打开屏幕保护程序,nlog不会写入日志,就好像事件没有被拿起一样!

代码在

之下
[DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int SystemParametersInfo(int uAction, int uParam, ref int ipvParam, int fuWinini);

        const int SPI_GETSCREENSAVERRUNNING = 114;
        static int screenSaverRunning = -1;
        int ok = SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, ref screenSaverRunning, 0);

        private void ScreenSaver()
        {
            if (ok == 0)
            {
                Logger.Trace("SCREENSAVER OFF");
            }

            if (screenSaverRunning != 0)
            {
                Logger.Trace("SCREENSAVER ON");

            }
    }

0 个答案:

没有答案