EvtSubscribe_push.py 623 B

12345678910111213141516
  1. ## Demonstrates a "push" subscription with a callback function
  2. import win32evtlog
  3. query_text='*[System[Provider[@Name="Microsoft-Windows-Winlogon"]]]'
  4. def c(reason, context, evt):
  5. if reason==win32evtlog.EvtSubscribeActionError:
  6. print('EvtSubscribeActionError')
  7. elif reason==win32evtlog.EvtSubscribeActionDeliver:
  8. print('EvtSubscribeActionDeliver')
  9. else:
  10. print('??? Unknown action ???', reason)
  11. context.append(win32evtlog.EvtRender(evt, win32evtlog.EvtRenderEventXml))
  12. return 0
  13. evttext=[]
  14. s=win32evtlog.EvtSubscribe('System', win32evtlog.EvtSubscribeStartAtOldestRecord, Query='*', Callback=c, Context=evttext)