Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading the event log from Delphi

Status
Not open for further replies.

Miker75

Vendor
Jan 7, 2004
35
0
0
US
Hi All,

Not sure if this is the right forum for this question (at least it's half right!). I need to read the NT event log from Delphi, but have found dozens of source snippets that show how to write to it, but none to read from it. Does anyone have some information on how to do this?

Michael


HP Certified Technician
 
Miker75

Although this isn't Delphi (hopefully you are able to translate this into something usefull), this what I use to extract information from the event logs (It is written in FoxPro and makes use of Window Scripting and Windows Management Instrumentation)
Code:
lcComputer = "."
loWMIService = Getobject("winmgmts:" ;
    + "{impersonationLevel=impersonate}!\\" + lcComputer + "\root\cimv2")
colLoggedEvents = loWMIService.ExecQuery ;
    ("Select * from Win32_NTLogEvent Where Logfile = 'Application'")
CREATE CURSOR Eventlog (category i,compname c(20),eventcode i,message m,;
recordn i,source c(80),time c(30),eventtype c(15),user c(15))
For Each loEvent In colLoggedEvents
   INSERT INTO Eventlog (category,compname,eventcode,;
   message,recordn,source,time,eventtype,user) VALUES (loEvent.Category,;
   loEvent.ComputerName,loEvent.EventCode,TRANSFORM(loEvent.message),loEvent.RecordNumber,;
   loEvent.SourceName,loEvent.TimeWritten,loEvent.Type,TRANSFORM(loEvent.user))
Next
SELECT eventlog
BROWSE nowait



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top