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.

49 lines
1.3 KiB

  1. #include "precomp.h"
  2. #include <evtlog.h>
  3. #define SRVC_NAME TEXT("mnmsrvc")
  4. //
  5. // FUNCTION: AddToMessageLog(LPTSTR lpszMsg)
  6. //
  7. // PURPOSE: Allows any thread to log an error message
  8. //
  9. // PARAMETERS:
  10. // lpszMsg - text for message
  11. //
  12. // RETURN VALUE:
  13. // none
  14. //
  15. // COMMENTS:
  16. //
  17. VOID AddToMessageLog(WORD wType, WORD wCategory, DWORD dwEvtId, LPTSTR lpszMsg)
  18. {
  19. HANDLE hEventSource;
  20. LPTSTR lpszStrings[2];
  21. int cSz = 0;
  22. hEventSource = RegisterEventSource(NULL, SRVC_NAME);
  23. if (NULL != lpszMsg)
  24. {
  25. cSz = 1;
  26. lpszStrings[0] = lpszMsg;
  27. }
  28. if (hEventSource != NULL) {
  29. ReportEvent(hEventSource, // handle of event source
  30. wType, // event type
  31. wCategory, // event category
  32. dwEvtId, // event ID
  33. NULL, // current user's SID
  34. (WORD)cSz, // strings in lpszStrings
  35. 0, // no bytes of raw data
  36. 0 == cSz ? NULL : (LPCTSTR*)lpszStrings, // array of error strings
  37. NULL); // no raw data
  38. (VOID) DeregisterEventSource(hEventSource);
  39. }
  40. }
  41.