Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.0 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: LgPowerLock.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of LgPowerLock.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "LgPowerLock.h"
  16. #include "LgLogger.h"
  17. CLgPowerLock::CLgPowerLock()
  18. {
  19. m_bScreenSaveActive = FALSE;
  20. m_bLowPowerActive = FALSE;
  21. m_bPowerOffActive = FALSE;
  22. m_bLocked = FALSE;
  23. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgPowerLock::CLgPowerLock" );
  24. }
  25. CLgPowerLock::~CLgPowerLock()
  26. {
  27. Unlock();
  28. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgPowerLock::~CLgPowerLock" );
  29. }
  30. BOOL CLgPowerLock::Lock()
  31. {
  32. if( !m_bLocked )
  33. {
  34. ::SystemParametersInfo( SPI_GETSCREENSAVEACTIVE, 0, &m_bScreenSaveActive, 0 );
  35. ::SystemParametersInfo( SPI_GETLOWPOWERACTIVE, 0, &m_bLowPowerActive, 0 );
  36. ::SystemParametersInfo( SPI_GETPOWEROFFACTIVE, 0, &m_bPowerOffActive, 0 );
  37. ::SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0 );
  38. ::SystemParametersInfo( SPI_SETLOWPOWERACTIVE, FALSE, NULL, 0 );
  39. ::SystemParametersInfo( SPI_SETPOWEROFFACTIVE, FALSE, NULL, 0 );
  40. ::SystemParametersInfo( SPI_SETSCREENSAVERRUNNING, TRUE, NULL, 0 );
  41. m_bLocked = TRUE;
  42. }
  43. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgPowerLock::Lock" );
  44. return TRUE;
  45. }
  46. void CLgPowerLock::Unlock()
  47. {
  48. if( m_bLocked )
  49. {
  50. ::SystemParametersInfo( SPI_SETSCREENSAVERRUNNING, FALSE, NULL, 0 );
  51. ::SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, m_bScreenSaveActive, NULL, 0 );
  52. ::SystemParametersInfo( SPI_SETLOWPOWERACTIVE, m_bLowPowerActive, NULL, 0 );
  53. ::SystemParametersInfo( SPI_SETPOWEROFFACTIVE, m_bPowerOffActive, NULL, 0 );
  54. m_bLocked = FALSE;
  55. }
  56. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, "CLgPowerLock::Unlock" );
  57. }