ifddlZddlZddlZddlZddlZddZdZdZedkr edSdS)N Applicationctj||}tj|}d} tj|tjtjzd}|sn.|D]}t j||}|jV tj ||j\} } } | d| } n)#tj $rt|j} YnwxYwd| } nd} |rtd|j|j| rt|  t|#t$$r/tdtt'|YwxYw|t)|z }_||krtd|dn#td ||fztd tj|dS) Nr/zEvent associated with user z&Event record from {!r} generated at {}z3(unicode error printing message: repr() follows...)zSuccessfully read allrecordsz4Couldn't get all records - reported %d, but found %dzJ(Note that some other app may have written records while we were running!)) win32evtlog OpenEventLogGetNumberOfEventLogRecords ReadEventLogEVENTLOG_BACKWARDS_READEVENTLOG_SEQUENTIAL_READwin32evtlogutilSafeFormatMessageSid win32securityLookupAccountSiderrorstrprintformat SourceName TimeGeneratedFormat UnicodeErrorreprlen CloseEventLog)computerlogTypedumpEachRecordh numRecordsnumobjectsobjectmsgdomainusertypsidDesc user_descs FC:\PYTHON\_runtimes\venv\Lib\site-packages\win32/Demos/eventLogDemo.pyReadLogr-sN 733A7::J C$*  /+2V V       % %F!3FGDDCz%.(5(F &*))%FD#"(00$00GG$*...!&*ooGGG.C'CC   %<CC)6+?+F+F+H+H %)$$$%#JJJJ#%%%OPPP$s))$$$$$% % s7||I$LS %z9==== BjRUEV V     X   a     s$%B&&#C  C *D::5E32E3ctdtdtdtdtdtddS)Nz!Writes an event to the event log.z"-w : Don't write any test records.z-r : Don't read the event logz=-c : computerName : Process the log on the specified computerz -v : Verbosez>-t : LogType - Use the specified log - default = 'Application')rr,usager1Asa -... ./// )*** IJJJ . JKKKKKr0c:ddl}ddl}||jddd\}}d}dx}}d}d}t|dkrt dt dS|D]E\} } | dkr| }| dkr| }| dvrt dS| d krd}| d krd}| d kr|dz }F|rt j} tj | tj } tj | tj d} tj|d d dgd| tj|dt jddgd| tj|dt jddgd| t d|rt'|||dkdSdS)Nrrz rwh?c:t:vrz Invalid argsz-tz-c)z-hz-?z-rz-wz-vzThe message text for event 2zAnother insertsRawData)stringsdatasidz A warningzAn even more dire warning) eventTyper4r5r6zAn infoz Too much infoz'Successfully wrote 3 records to the log)getoptsysargvrrr1win32apiGetCurrentProcessrOpenProcessTokenwin32con TOKEN_READGetTokenInformation TokenUserr ReportEventrEVENTLOG_WARNING_TYPEEVENTLOG_INFORMATION_TYPEr-)r8r9optsargsrdo_readdo_writerverboseoptvalphthmy_sids r,testrOJsMMMJJJsx|[99JD$HGhGG 4yy1}} n q  S $;;G $;;H ,   GGG FF $;;G $;;H $;; qLG9  ' ) )  +B0C D D22}7NOOPQR#  35EF      #  !7 "=>      #  !;0      78880'7Q;/////00r0__main__)rr) r;r>rrrr-r1rO__name__r/r0r,rRs6!6!6!6!rLLL<0<0<0~ zDFFFFFr0