[python-win32] help with Event Log

Jorgensen, Jens jens.jorgensen@tallan.com
Thu, 20 Dec 2001 14:10:54 -0600


I don't think that an EventLog handle is valid for use with any of the 
Wait* functions. Why not just read to the end of the event log (when the 
read function will return an empty list) and then sleep for 10 seconds, 
and try to read again?

import win32evtlog, time, win32gui

h = win32evtlog.OpenEventLog('your computer', 'Application')

while 1 :
    l = win32evtlog.ReadEventLog(h,  
win32evtlog.EVENTLOG_SEQUENTIAL_READ|win32evtlog.EVENTLOG_FORWARDS_READ, 0)
    if not l :
        time.sleep(10)
        continue
    for i in l :
        if <test to see if event is of interest> :
            win32gui.MessageBox(0, 'an intruder is detected', 'intruder 
alert', 0)

Ivan Hernandez Puga wrote:

>Hello. I'm trying to make a script to warn me when an event arrives to the Windows 2000 event log.
>I have successful listed events and that things, but when trying to use WaitForMultipleObjects, WaitForMultipleObjectsEx or WaitForSingleObject and WaitForSingleObjectex I found no way to create a valid Event Handler.
>Some help here? I don't know too much, if you can make a "script kiddie" example I would appreciate it very much.
>Thanks
>
>Ivan Hernandez
>
>
>_______________________________________________
>Python-win32 mailing list
>Python-win32@python.org
>http://mail.python.org/mailman/listinfo/python-win32
>


-- 
Jens B. Jorgensen
jens.jorgensen@tallan.com