|
|
//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright � 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: LgPowerLock.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of LgPowerLock.cpp
//----------------------------------------------------------------------------
#include "stdafx.h"
#include "LgPowerLock.h"
#include "LgLogger.h"
CLgPowerLock::CLgPowerLock(){ m_bScreenSaveActive = FALSE; m_bLowPowerActive = FALSE; m_bPowerOffActive = FALSE; m_bLocked = FALSE;
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgPowerLock::CLgPowerLock" );}
CLgPowerLock::~CLgPowerLock(){ Unlock();
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgPowerLock::~CLgPowerLock" );}
BOOL CLgPowerLock::Lock(){ if( !m_bLocked ) { ::SystemParametersInfo( SPI_GETSCREENSAVEACTIVE, 0, &m_bScreenSaveActive, 0 ); ::SystemParametersInfo( SPI_GETLOWPOWERACTIVE, 0, &m_bLowPowerActive, 0 ); ::SystemParametersInfo( SPI_GETPOWEROFFACTIVE, 0, &m_bPowerOffActive, 0 );
::SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0 ); ::SystemParametersInfo( SPI_SETLOWPOWERACTIVE, FALSE, NULL, 0 ); ::SystemParametersInfo( SPI_SETPOWEROFFACTIVE, FALSE, NULL, 0 ); ::SystemParametersInfo( SPI_SETSCREENSAVERRUNNING, TRUE, NULL, 0 );
m_bLocked = TRUE; }
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgPowerLock::Lock" );
return TRUE;}
void CLgPowerLock::Unlock(){ if( m_bLocked ) { ::SystemParametersInfo( SPI_SETSCREENSAVERRUNNING, FALSE, NULL, 0 ); ::SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, m_bScreenSaveActive, NULL, 0 ); ::SystemParametersInfo( SPI_SETLOWPOWERACTIVE, m_bLowPowerActive, NULL, 0 ); ::SystemParametersInfo( SPI_SETPOWEROFFACTIVE, m_bPowerOffActive, NULL, 0 );
m_bLocked = FALSE; }
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgPowerLock::Unlock" );}
|