This is from one of the forums, so you can test it yourself, but the idea is
to use interop to get the state from the SPI enum:
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SystemParametersInfo(int uAction,
int uParam, ref int lpvParam, int fuWinIni);
const int SPI_GETSCREENSAVERRUNNING = 114;
int screenSaverRunning = -1;
// is the screen saver running?
int ok = SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, ref
screenSaverRunning, 0);
if (ok == 0)
{
Console.WriteLine("Call to SystemParametersInfo failed.");
}
if (screenSaverRunning != 0)
{
// screen saver is running
}
ok,
aq
"Anthony" <Anthony@discussions.microsoft.com> wrote in message
news:F396F6C6-7993-445D-B470-E6033666CAB0@microsoft.com...[color=blue]
> In C++ you can detect the screensaver state by using something like:
>
> BOOL b=SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, NULL, &bOn, FALSE);
>
> Is there an equivalent method that I can use in C#? If not, how can I
> determine the state of the screen saver?
>
> --
> -Anthony[/color]