Software guru, Inc

Real World Solutions

The Guru's Blog

Write to the Eventlog in Delphi

Dec 13

Written by:
12/13/2012 7:17 PM  RssIcon

Delphi Write to Event Log

uses Windows;

...

const

SDefaultSource = 'ELog';

...

// TEventLogger is not used because the current RTL supports only local servers

function WriteEventLog(AEntry: string;

AServer: string ='';

ASource: string = SDefaultSource;

AEventType: word = EVENTLOG_INFORMATION_TYPE;

AEventId: word = 0;

AEventCategory: word = 0

): boolean;

var

EventLog: integer;

P: Pointer;

begin

Result := False;

P := PWideChar(AEntry);

if Length(AServer) = 0 then // Write to the local machine

EventLog := RegisterEventSource(nil, PWideChar(ASource))

else // Write to a remote machine

EventLog := RegisterEventSource(PWideChar(AServer),

PWideChar(ASource));

if EventLog <> 0 then

try

ReportEvent(EventLog, // event log handle

AEventType, // event type

AEventCategory, // category zero

AEventId, // event identifier

nil, // no user security identifier

1, // one substitution string

0, // no data

@P, // pointer to string array

nil); // pointer to data

Result := True;

finally

DeregisterEventSource(EventLog);

end;

1 comment(s) so far...


Gravatar

Re: Write to the Eventlog in Delphi

Delphi provides us the knowledge to improve the coding language. Coding language is while we making some kind of software. Some software provides good coding language and helpful for the development of the software. It is a good site. Thank you! You can write my essay 4 me to get valuable instruction with the help of native writers.

By Cynthia J. Lafountain on   1/20/2017 1:21 AM

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment   Cancel 
You must be logged in and have permission to create or edit a blog.