Avviare System Screensaver da Windows Form C #
-
06-07-2019 - |
Domanda
Speriamo che sia semplice, ma qualcuno può fornire qualche semplice codice c # che lanci lo screensaver attualmente configurato?
Soluzione
Ecco un buon sito che mostra come lavorare con tutti gli aspetti dello screensaver. Vedere i commenti alla fine per il codice per avviare lo screensaver.
http://www.codeproject.com/KB/cs/ScreenSaverControl.aspx
[DllImport("user32.dll", EntryPoint = "GetDesktopWindow")]
private static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
//...
private const int SC_SCREENSAVE = 0xF140;
private const int WM_SYSCOMMAND = 0x0112;
//...
public static void SetScreenSaverRunning()
{
SendMessage
(GetDesktopWindow(), WM_SYSCOMMAND, SC_SCREENSAVE, 0);
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow