Hello Peter,

Here is an example. I did some cut/copy from one of my applicaitons to
only have the relevant part. I hope it is still working :)

About the DLL and all the things you find about the message compiler and
so, this is all not true. You only have to set somewhere your
application name+path somewhere in registry.  I hope I can find this
back for you. I come back if I find it :)

type
  TLogType = (ltError, ltWarning, ltSystem);
  TEvent = (evSystem,
            evTx,
            evRx);

  TEventLog = class
  private
    FName: string;
    FEventLog: integer;
    FActive: boolean;
    FLocalFile: string;
  public
    constructor Create(const Name: string); reintroduce;
    destructor Destroy; override;
    procedure Add(EventType: TLogType; Event: TEvent; Msg: string); overload;
  published
    property LocalFile: string read FLocalFile write FLocalFile;
    property Active: boolean read FActive write FActive;
  end;

implementation

{ TEventLog }

constructor TEventLog.Create(const Name: string);
begin
   inherited;
   FName := Name;
   FEventLog := RegisterEventSource(nil, PChar(FName));
end;

destructor TEventLog.Destroy;
begin
   DeRegisterEventSource(FEventLog);
   inherited;
end;

procedure TEventLog.Add(EventType: TLogType; Event: TEvent; Msg: string);
var
   P: Pointer;
   F: integer;
   DT: string;
begin
   if not FActive then
      Exit;
   P := PChar(Msg);
   ReportEvent(FEventLog, Ord(EventType) + 1, 0, Ord(Event), nil, 1, 0, @P, 
nil);
end;

---
Rgds, Wilfried
http://www.mestdagh.biz

__________________________________________________
Delphi-Talk mailing list -> Delphi-Talk@elists.org
http://www.elists.org/mailman/listinfo/delphi-talk

Reply via email to