Source code of Windows XP (NT5)
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.

52 lines
1.0 KiB

  1. //=======================================================================
  2. //
  3. // Copyright (c) 1999 Microsoft Corporation. All Rights Reserved.
  4. //
  5. // File: servpaus.h
  6. //
  7. // Purpose: Service Pauser class. Allows pausing the taskscheduler and then automatically
  8. // restoring it to original state if we wanted more services to be paused like
  9. // screen savers etc, we will add methods here
  10. //
  11. //=======================================================================
  12. #ifndef _SERVPAUS_H
  13. #define _SERVPAUS_H
  14. #include <windows.h>
  15. //
  16. // CServPauser class
  17. //
  18. class CServPauser
  19. {
  20. public:
  21. void PauseTaskScheduler()
  22. {
  23. iSageRestoreTo = EnableSage(DISABLE_AGENT);
  24. bSageRestore = (iSageRestoreTo == ENABLE_AGENT);
  25. }
  26. CServPauser() :
  27. bSageRestore(FALSE)
  28. {
  29. }
  30. ~CServPauser()
  31. {
  32. if (bSageRestore)
  33. {
  34. EnableSage(iSageRestoreTo);
  35. }
  36. }
  37. private:
  38. enum {ENABLE_AGENT = 1, DISABLE_AGENT = 2, GET_AGENT_STATUS = 3}; // from sage.h
  39. BOOL bSageRestore;
  40. int iSageRestoreTo;
  41. int EnableSage(int iEnable);
  42. };
  43. #endif // _SERVPAUS_H