procedure Write2EventLog(Source,Msg: string);
var h: THandle;
ss: array [0..0] of pchar;
begin
ss[0] := pchar(Msg);
h := RegisterEventSource(nil, // uses local computer
pchar(Source)); // source name
if h <> 0 then
ReportEvent(h, // event log handle
EVENTLOG_ERROR_TYPE, // event type
0, // category zero
0, // event identifier
nil, // no user security identifier
1, // one substitution string
0, // no data
@ss, // pointer to string array
nil); // pointer to data
DeregisterEventSource(h);
end;