【发布时间】:2018-06-26 06:41:11
【问题描述】:
我正在开发一个需要在 Windows 事件日志中通知特定事件的程序。我不知道需要在 NotifyChangeEventLog() 函数中指定的参数。
以下是我一直在使用的代码:
import win32evtlog
server = 'localhost' # name of the target computer to get event logs
logtype = 'Application' # 'Application' # 'Security'
hand = win32evtlog.OpenEventLog(server,logtype)
flags =
win32evtlog.EVENTLOG_BACKWARDS_READ|win32evtlog.EVENTLOG_SEQUENTIAL_READ
total = win32evtlog.GetNumberOfEventLogRecords(hand)
print total
notify = win32evtlog.NotifyChangeEventLog(hand, 1)
我收到此错误:
notify = win32evtlog.NotifyChangeEventLog(hand, 1)
Traceback(最近一次调用最后一次):
文件“”,第 1 行,在
notify = win32evtlog.NotifyChangeEventLog(hand, 1)
error: (6, 'NotifyChangeEventLog', '句柄无效。')
参数是什么?
【问题讨论】:
标签: python windows wmi event-log pywin32