Leaked source code of windows server 2003
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.

84 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. g_bSuccess = SystemParametersInfoA(SPI_GETSCREENSAVEACTIVE, 0, &g_bActive, 0) &&
  34. SystemParametersInfoA(SPI_SETSCREENSAVEACTIVE, FALSE, NULL, 0);
  35. if (!g_bSuccess) {
  36. LOGN( eDbgLevelError, "[INIT] Failed to disable screen saver");
  37. }
  38. } else if (fdwReason == DLL_PROCESS_DETACH) {
  39. //
  40. // Restore original screen saver state
  41. //
  42. if (g_bSuccess) {
  43. SystemParametersInfoA(SPI_SETSCREENSAVEACTIVE, g_bActive, NULL, 0);
  44. }
  45. }
  46. return TRUE;
  47. }
  48. /*++
  49. Register hooked functions
  50. --*/
  51. HOOK_BEGIN
  52. CALL_NOTIFY_FUNCTION
  53. HOOK_END
  54. IMPLEMENT_SHIM_END