コード例 #1
0
 private static bool KillScreenSaverFunc(IntPtr hWnd, IntPtr lParam)
 {
     if (ScreenSaver.IsWindowVisible(hWnd))
     {
         ScreenSaver.PostMessage(hWnd, 16, 0, 0);
     }
     return(true);
 }
コード例 #2
0
        public static void KillScreenSaver()
        {
            IntPtr hDesktop = ScreenSaver.OpenDesktop("Screen-saver", 0, false, 129U);

            if (hDesktop != IntPtr.Zero)
            {
                ScreenSaver.EnumDesktopWindows(hDesktop, new ScreenSaver.EnumDesktopWindowsProc(ScreenSaver.KillScreenSaverFunc), IntPtr.Zero);
                ScreenSaver.CloseDesktop(hDesktop);
            }
            else
            {
                ScreenSaver.PostMessage(ScreenSaver.GetForegroundWindow(), 16, 0, 0);
            }
        }