Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Reading the Event Log

Reading the Event Log

Reading the Event Log

Hi All,

  Does anyone know how to read the NT event log?  Any help would be greatly appreciated!



HP Certified Technician

RE: Reading the Event Log

try opening it with notepad


Everyone has a right to my opinion.
Great Delphi Websites FAQ102-5352

RE: Reading the Event Log

Hi there,

try this :


unit u_eventlog;


uses  SysUtils, Windows;

  TEventLog = Class
    procedure Add(EvtType : integer; EvtMsg : string);

  NTEventLog : TEventlog;


{$R U_EVENTLOG.RES} // include message resource

procedure TEventlog.Add(EvtType : integer; EvtMsg : string);

var Log                        : THandle;
    Category,EventID           : Integer;
    Data,DataSize              : Integer;
    P                          : PChar;

 if (Log <> 0) then
   Category:=0;     // no specific category
   EventID := 1000; // only one event defined, message resource has message 1000 included
   Data := 0;       // no data
   DataSize := 0;   // thus size is 0
   if not ReportEvent(Log,EvtType,Category,EventID,nil,1,DataSize,@P,@Data) then
    // report any error here to your debugger
 else Debug.Output('Could not open Windows Application Event log',LVL_NORM);

  if Assigned(NTEventLog) then FreeAndNil(NTEventLog);

you'll have to remove the '{$R U_EVENTLOG.RES} // include message resource' line because you don't have that file.
it's a message resource forthe eventlog but it works without it


 What You See Is What You Get

RE: Reading the Event Log

Thanks for the reply whosrdaddy, but what I need is a procedure to read the event log.  I believe the code you posted writes to the event log, but does not read it.

HP Certified Technician

RE: Reading the Event Log

For as far as I'm aware, the NT Log files are plain text and can be loaded into any TStrings you want.


Everyone has a right to my opinion.
Great Delphi Websites FAQ102-5352

RE: Reading the Event Log

Hi Whosrdaddy,

  I'd seen that website before but had lost track of it!  Thanks very much.  From what I've seen so far it's exactly what I need.

HP Certified Technician

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close