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.

85 lines
1.5 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. DisableScreenSaver.cpp
  5. Abstract:
  6. This shim is for apps that do bad things when screen savers are active.
  7. Notes:
  8. This is a general purpose shim.
  9. History:
  10. 02/07/2001 linstev Created
  11. --*/
  12. #include "precomp.h"
  13. IMPLEMENT_SHIM_BEGIN(DisableScreenSaver)
  14. #include "ShimHookMacro.h"
  15. APIHOOK_ENUM_BEGIN
  16. APIHOOK_ENUM_END
  17. // Store the state of the active flag
  18. BOOL g_bActive = TRUE;
  19. BOOL g_bSuccess = FALSE;
  20. /*++
  21. Turn screen saver off and on again on detach.
  22. --*/
  23. BOOL
  24. NOTIFY_FUNCTION(
  25. DWORD fdwReason
  26. )
  27. {
  28. if (fdwReason == SHIM_STATIC_DLLS_INITIALIZED) {
  29. //
  30. // Turn OFF screen saver: detect success/failure so we know if we can
  31. // safely clean up
  32. //
  33. BOOL bOff = FALSE;
  34. g_bSuccess = SystemParametersInfoA(SPI_GETSCREENSAVEACTIVE, 0, &g_bActive, 0) &&
  35. SystemParametersInfoA(SPI_SETSCREENSAVEACTIVE, 0, &bOff, 0);
  36. if (!g_bSuccess) {
  37. LOGN( eDbgLevelError, "[INIT] Failed to disable screen saver");
  38. }
  39. } else if (fdwReason == DLL_PROCESS_DETACH) {
  40. //
  41. // Restore original screen saver state
  42. //
  43. if (g_bSuccess) {
  44. SystemParametersInfoA(SPI_SETSCREENSAVEACTIVE, g_bActive, NULL, 0);
  45. }
  46. }
  47. return TRUE;
  48. }
  49. /*++
  50. Register hooked functions
  51. --*/
  52. HOOK_BEGIN
  53. CALL_NOTIFY_FUNCTION
  54. HOOK_END
  55. IMPLEMENT_SHIM_END