unit MonServMain;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ComObj,
ActiveX, AxCtrls, Classes, Monserv_TLB, StdVcl;
type
TMonServ =
class(TAutoObject, IConnectionPointContainer, IMonServ)
private
{ Private-Deklarationen }
FConnectionPoints: TConnectionPoints;
FConnectionPoint: TConnectionPoint;
FEvents: IMonServEvents;
{ Hinweis: FEvents unterhält eine *einzelne* Ereignissenke. Verwenden Sie
für den Zugriff auf mehrere Ereignissenken FConnectionPoint.SinkList und
durchlaufen Sie die Liste der Senken. }
public
procedure Initialize;
override;
protected
{ Protected-Deklarationen }
property ConnectionPoints: TConnectionPoints
read FConnectionPoints
implements IConnectionPointContainer;
procedure EventSinkChanged(
const EventSink: IUnknown);
override;
procedure LogOffUser(
const Server, Username: WideString);
safecall;
end;
implementation
uses ComServ;
procedure TMonServ.EventSinkChanged(
const EventSink: IUnknown);
begin
FEvents := EventSink
as IMonServEvents;
end;
procedure TMonServ.Initialize;
begin
inherited Initialize;
FConnectionPoints := TConnectionPoints.Create(Self);
if AutoFactory.EventTypeInfo <>
nil then
FConnectionPoint := FConnectionPoints.CreateConnectionPoint(
AutoFactory.EventIID, ckSingle, EventConnect)
else FConnectionPoint :=
nil;
end;
procedure TMonServ.LogOffUser(
const Server, Username: WideString);
var
i, nCount : integer;
begin
nCount := FConnectionPoint.SinkList.Count;
for i:= 0
to nCount-1
do begin
if FConnectionPoint.SinkList[i] <>
NIL then
IMonservEvents(FConnectionPoint.SinkList.Items[i]).MonMessage('
LogOff ' + Username + '
on ' + Server,nCount);
end;
// FEvents.MonMessage('LogOff ' + Username + ' on ' + Server,1);
end;
initialization
TAutoObjectFactory.Create(ComServer, TMonServ, Class_MonServ_,
ciMultiInstance, tmApartment);
end.