///
/// Summary description for SystemParameterInfoWrapper.
///
///
/// A lot of this was found on
/// http://www.dotnet247.com/247reference/msgs/45/225361.asp
///note: this will only work on win 2000 or higher, NT doesn't support the screensaver running on SPI
///
public class SystemParameterInfoWrapper
{
public static int SPI_GETSCREENSAVEACTIVE = 16;
public static int SPI_GETSCREENSAVERRUNNING = 114;
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int SystemParametersInfo(int uAction,int uParam, ref int lpvParam, int fuWinIni);
public static bool IsScreenSaverRunning()
{p; {
bool running = false;
try
{
int screenSaverRunning = -1;
// is the screen saver running?
int ok = SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, ref
screenSaverRunning, 0);
if (ok != 0)
{
if (screenSaverRunning != 0)
{p; {
// screen saver is running
running = true;
}
}
}
catch (Exception e)
{
log.Error("Exception while determining if screensaver is running",e);
}
return running;
}
public SystemParameterInfoWrapper()
{p; {
}
}
|