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
2.5 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: timers.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * This module contains GDI-callable exports from user. No user code
  7. * should call any of these routines.
  8. *
  9. * History:
  10. * 3-Jun-1998 AndrewGo Created.
  11. \***************************************************************************/
  12. #include "precomp.h"
  13. #pragma hdrstop
  14. /***************************************************************************\
  15. * UserSetTimer
  16. *
  17. * GDI-callable routine to enable a system timer on the RIT.
  18. *
  19. * 6/2/98 AndrewGo Created
  20. \***************************************************************************/
  21. UINT_PTR UserSetTimer(
  22. UINT dwElapse,
  23. PVOID pTimerFunc)
  24. {
  25. UINT_PTR id;
  26. PTIMER ptmr;
  27. /*
  28. * GDI may call during ChangeDisplaySettings, in which case the
  29. * critical section will already be held. GDI may also call during
  30. * CreateDC("Device"), in which case the critical section will not
  31. * already be held.
  32. */
  33. BEGIN_REENTERCRIT();
  34. /*
  35. * If the RIT hasn't been started yet, let GDI know this by returning
  36. * failure. Once we've initialized the RIT, we'll let GDI know
  37. * that GDI can start its timers by calling GreStartTimers().
  38. */
  39. if (gptmrMaster) {
  40. id = InternalSetTimer(NULL, 0, dwElapse, (TIMERPROC_PWND) pTimerFunc, TMRF_RIT);
  41. /*
  42. * We don't want cleanup to be done on thread termination. Rather
  43. * than creating a new flag and adding more code to InternalSetTimer,
  44. * we disable cleanup by modifying the timer directly.
  45. */
  46. if (id) {
  47. ptmr = FindTimer(NULL, id, TMRF_RIT, FALSE);
  48. UserAssert(ptmr);
  49. ptmr->ptiOptCreator = NULL;
  50. }
  51. } else {
  52. id = 0;
  53. }
  54. END_REENTERCRIT();
  55. return id;
  56. }
  57. /***************************************************************************\
  58. * UserKillTimer
  59. *
  60. * 6/2/98 AndrewGo Created
  61. \***************************************************************************/
  62. VOID UserKillTimer(
  63. UINT_PTR nID)
  64. {
  65. /*
  66. * GDI may call during ChangeDisplaySettings, in which case the
  67. * critical section will already be held. GDI may also call any
  68. * time its PDEV reference counts go to zero, in which case the
  69. * critical section will not already be held.
  70. */
  71. BEGIN_REENTERCRIT();
  72. KILLRITTIMER(NULL, nID);
  73. END_REENTERCRIT();
  74. }