unit UnCoOuterObj;

interface

uses
  Windows, ComObj, ActiveX, AggrLib_TLB, StdVcl;

type
  TCoOuterObj = class(TAutoObject, ICoOuterObj)
  protected
    { Protected declarations }
  public
   function ObjQueryInterface(const IID: TGUID; out Obj): HResult;override;
  end;

implementation

uses ComServ, UnMyAggrObj;

{ TCoOuterObj }

function TCoOuterObj.ObjQueryInterface(const IID: TGUID; out Obj): HResult;
begin
  Result := E_NOINTERFACE;
  Pointer(Obj) := nil;
  if IsEqualIID(IID, IID_IMyXTimer) then
    begin
      IMyXTimer(Obj) := IMyXTimer(TMyAggrObj.Create(IUnknown(Self)));
      if Pointer(Obj)<>nil then
       Result := S_OK;
    end else
  if GetInterface(IID, Obj) then
     Result := S_OK;
end;

initialization
  TAutoObjectFactory.Create(ComServer, TCoOuterObj, Class_CoOuterObj,
    ciMultiInstance, tmApartment);
end.
