INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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!

*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.

Jobs

Reading the Event Log

Reading the Event Log

(OP)
Hi All,

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

Thanks

Michael

HP Certified Technician

RE: Reading the Event Log

try opening it with notepad

  BobbaFet  

Everyone has a right to my opinion.
[/b]
Great Delphi Websites FAQ102-5352

RE: Reading the Event Log

Hi there,

try this :

CODE

unit u_eventlog;

interface

uses  SysUtils, Windows;

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

var
  NTEventLog : TEventlog;

implementation


{$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;

begin
 Log:=OpenEventLog(nil,STR_NAME_APPLICATION);
 if (Log <> 0) then
  begin
   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
   P:=Pointer(EvtMsg);
   if not ReportEvent(Log,EvtType,Category,EventID,nil,1,DataSize,@P,@Data) then
    // report any error here to your debugger
   else
   CloseEventLog(Log);
  end
 else Debug.Output('Could not open Windows Application Event log',LVL_NORM);
end;



initialization
 try
  NTEventLog:=TEventLog.Create;
 finally
 end;
finalization
 try
  if Assigned(NTEventLog) then FreeAndNil(NTEventLog);
 finally
 end;
end.

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


cheers

--------------------------------------
 What You See Is What You Get

RE: Reading the Event Log

(OP)
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.

  BobbaFet  

Everyone has a right to my opinion.
[/b]
Great Delphi Websites FAQ102-5352

RE: Reading the Event Log

(OP)
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!

Resources

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