event.cpp 561 B

1234567891011121314151617181920212223
  1. #include "nssm.h"
  2. /* Log a message to the Event Log */
  3. void log_event(unsigned short type, unsigned long id, ...) {
  4. va_list arg;
  5. int count;
  6. char *s;
  7. char *strings[6];
  8. /* Open event log */
  9. HANDLE handle = RegisterEventSource(0, TEXT(NSSM));
  10. if (! handle) return;
  11. /* Log it */
  12. count = 0;
  13. va_start(arg, id);
  14. while ((s = va_arg(arg, char *))) strings[count++] = s;
  15. va_end(arg);
  16. ReportEvent(handle, type, 0, id, 0, count, 0, (const char **) strings, 0);
  17. /* Close event log */
  18. DeregisterEventSource(handle);
  19. }