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.

100 lines
1.8 KiB

  1. /*++
  2. Copyright (c) 2000, Microsoft Corporation
  3. Module Name:
  4. Abstract:
  5. Author:
  6. Savas Guven (savasg) 27-Nov-2000
  7. Revision History:
  8. --*/
  9. #include "stdafx.h"
  10. #include "util.h"
  11. //
  12. // GLOBALS
  13. //
  14. HANDLE g_TimerQueueHandle = NULL;
  15. void
  16. ErrorOut(void)
  17. {
  18. LPVOID lpMsgBuf;
  19. FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
  20. FORMAT_MESSAGE_FROM_SYSTEM |
  21. FORMAT_MESSAGE_IGNORE_INSERTS,
  22. NULL,
  23. GetLastError(),
  24. MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
  25. (LPTSTR) &lpMsgBuf,
  26. 0,
  27. NULL );
  28. // Process any inserts in lpMsgBuf.
  29. // ...
  30. // Display the string.
  31. MessageBox( NULL,
  32. (LPCTSTR)lpMsgBuf,
  33. _T("Error"),
  34. MB_OK | MB_ICONINFORMATION );
  35. // Free the buffer.
  36. LocalFree( lpMsgBuf );
  37. }
  38. PTIMER_CONTEXT
  39. AllocateAndSetTimer(
  40. ULONG uContext,
  41. ULONG timeOut,
  42. WAITORTIMERCALLBACK Callbackp
  43. )
  44. {
  45. ULONG Error = NO_ERROR;
  46. PTIMER_CONTEXT TimerContextp = NULL;
  47. TimerContextp = (PTIMER_CONTEXT) NH_ALLOCATE(sizeof(TIMER_CONTEXT));
  48. if(TimerContextp is NULL)
  49. {
  50. return NULL;
  51. }
  52. ZeroMemory(TimerContextp, sizeof(TIMER_CONTEXT));
  53. TimerContextp->TimerQueueHandle = g_TimerQueueHandle;
  54. TimerContextp->uContext = uContext;
  55. Error = CreateTimerQueueTimer(&TimerContextp->TimerHandle,
  56. g_TimerQueueHandle,
  57. Callbackp,
  58. TimerContextp,
  59. timeOut * 1000,
  60. 0,
  61. WT_EXECUTEDEFAULT);
  62. if(Error is 0)
  63. {
  64. NH_FREE(TimerContextp);
  65. return NULL;
  66. }
  67. return TimerContextp;
  68. }