Screen Saver notifications

I want to get notifications of various System Events in my C# app (Shut down, logoff, Session change, etc). So far I found that the SystemEvents class is very useful (http://msdn2.microsoft.com/en-us/library/microsoft.win32.systemevents_members.aspx)

However it is missing the notifications for Screen Saver start and stop. Does anybody have an idea to subscribe to Screen Saver events

Regards



Answer this question

Screen Saver notifications

  • vsnewbie

    Good Luck...I think your going to have to poll with that code...

    No such system event AFAIK.



  • ehrlich

    [DllImport("user32.dll", CharSet = CharSet.Auto)]

    static extern int SystemParametersInfo(int uAction,

    int uParam, ref int lpvParam, int fuWinIni);

    int screenSaverRunning = -1;

    int ok = SystemParametersInfo(114, 0, ref

    screenSaverRunning, 0);

    if (screenSaverRunning != 0)

    //it's running



  • Sabratha

    Thanks for the reply and hint.

    However, I need to trigger the event of a screen saver starts as soon it happens (by registering a delegate or to an event). I am doing a 3D preview that I want to stop as soon as the screen saver starts, and then resume the preview when the screen saver stops.

    Regards :)


  • Screen Saver notifications