unit AggrLib_TLB;

// ************************************************************************ //
// WARNING                                                                    
// -------                                                                    
// The types declared in this file were generated from data read from a       
// Type Library. If this type library is explicitly or indirectly (via        
// another type library referring to this type library) re-imported, or the   
// 'Refresh' command of the Type Library Editor activated while editing the   
// Type Library, the contents of this file will be regenerated and all        
// manual modifications will be lost.                                         
// ************************************************************************ //

// PASTLWTR : $Revision:   1.88  $
// File generated on 04.08.2000 12:42:10 from Type Library described below.

// *************************************************************************//
// NOTE:                                                                      
// Items guarded by $IFDEF_LIVE_SERVER_AT_DESIGN_TIME are used by properties  
// which return objects that may need to be explicitly created via a function 
// call prior to any access via the property. These items have been disabled  
// in order to prevent accidental use from within the object inspector. You   
// may enable them by defining LIVE_SERVER_AT_DESIGN_TIME or by selectively   
// removing them from the $IFDEF blocks. However, such items must still be    
// programmatically created via a method of the appropriate CoClass before    
// they can be used.                                                          
// ************************************************************************ //
// Type Lib: D:\_Projects3.1\aggregate_tst\AggrLib.tlb (1)
// IID\LCID: {569161BD-1CB9-45B8-B519-A2BE7214B11A}\0
// Helpfile: 
// DepndLst: 
//   (1) v2.0 stdole, (C:\WINNT\System32\stdole2.tlb)
//   (2) v4.0 StdVCL, (C:\WINNT\System32\STDVCL40.DLL)
// ************************************************************************ //
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers. 
interface

uses Windows, ActiveX, Classes, Graphics, OleServer, OleCtrls, StdVCL;

// *********************************************************************//
// GUIDS declared in the TypeLibrary. Following prefixes are used:        
//   Type Libraries     : LIBID_xxxx                                      
//   CoClasses          : CLASS_xxxx                                      
//   DISPInterfaces     : DIID_xxxx                                       
//   Non-DISP interfaces: IID_xxxx                                        
// *********************************************************************//
const
  // TypeLibrary Major and minor versions
  AggrLibMajorVersion = 1;
  AggrLibMinorVersion = 0;

  LIBID_AggrLib: TGUID = '{569161BD-1CB9-45B8-B519-A2BE7214B11A}';

  IID_ICoOuterObj: TGUID = '{BB35662B-C0C9-4402-B47D-001CF8E5E099}';
  CLASS_CoOuterObj: TGUID = '{9F29D601-BDE6-431A-BC2E-2FE29EEA06FF}';
  IID_ITypaMyAdvise: TGUID = '{95CBEC38-B6A2-4399-B430-B459262B5EE8}';
  IID_IMyXTimer: TGUID = '{4EFA4D3C-5814-4A03-BF04-844F159BB9FB}';
type

// *********************************************************************//
// Forward declaration of types defined in TypeLibrary                    
// *********************************************************************//
  ICoOuterObj = interface;
  ICoOuterObjDisp = dispinterface;
  ITypaMyAdvise = interface;
  IMyXTimer = interface;

// *********************************************************************//
// Declaration of CoClasses defined in Type Library                       
// (NOTE: Here we map each CoClass to its Default Interface)              
// *********************************************************************//
  CoOuterObj = ICoOuterObj;


// *********************************************************************//
// Interface: ICoOuterObj
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {BB35662B-C0C9-4402-B47D-001CF8E5E099}
// *********************************************************************//
  ICoOuterObj = interface(IDispatch)
    ['{BB35662B-C0C9-4402-B47D-001CF8E5E099}']
  end;

// *********************************************************************//
// DispIntf:  ICoOuterObjDisp
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {BB35662B-C0C9-4402-B47D-001CF8E5E099}
// *********************************************************************//
  ICoOuterObjDisp = dispinterface
    ['{BB35662B-C0C9-4402-B47D-001CF8E5E099}']
  end;

// *********************************************************************//
// Interface: ITypaMyAdvise
// Flags:     (0)
// GUID:      {95CBEC38-B6A2-4399-B430-B459262B5EE8}
// *********************************************************************//
  ITypaMyAdvise = interface(IUnknown)
    ['{95CBEC38-B6A2-4399-B430-B459262B5EE8}']
    procedure OnXTime; stdcall;
  end;

// *********************************************************************//
// Interface: IMyXTimer
// Flags:     (0)
// GUID:      {4EFA4D3C-5814-4A03-BF04-844F159BB9FB}
// *********************************************************************//
  IMyXTimer = interface(IUnknown)
    ['{4EFA4D3C-5814-4A03-BF04-844F159BB9FB}']
    function  SetAdvise(const Advs: ITypaMyAdvise): HResult; stdcall;
    function  Unadvise(const Advs: ITypaMyAdvise): HResult; stdcall;
    function  Start: HResult; stdcall;
    function  Stop: HResult; stdcall;
    function  SetInterval(Intrerval: Integer): HResult; stdcall;
  end;

// *********************************************************************//
// The Class CoCoOuterObj provides a Create and CreateRemote method to          
// create instances of the default interface ICoOuterObj exposed by              
// the CoClass CoOuterObj. The functions are intended to be used by             
// clients wishing to automate the CoClass objects exposed by the         
// server of this typelibrary.                                            
// *********************************************************************//
  CoCoOuterObj = class
    class function Create: ICoOuterObj;
    class function CreateRemote(const MachineName: string): ICoOuterObj;
  end;


// *********************************************************************//
// OLE Server Proxy class declaration
// Server Object    : TCoOuterObj
// Help String      : CoOuterObj Object
// Default Interface: ICoOuterObj
// Def. Intf. DISP? : No
// Event   Interface: 
// TypeFlags        : (2) CanCreate
// *********************************************************************//
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  TCoOuterObjProperties= class;
{$ENDIF}
  TCoOuterObj = class(TOleServer)
  private
    FIntf:        ICoOuterObj;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
    FProps:       TCoOuterObjProperties;
    function      GetServerProperties: TCoOuterObjProperties;
{$ENDIF}
    function      GetDefaultInterface: ICoOuterObj;
  protected
    procedure InitServerData; override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;
    procedure Connect; override;
    procedure ConnectTo(svrIntf: ICoOuterObj);
    procedure Disconnect; override;
    property  DefaultInterface: ICoOuterObj read GetDefaultInterface;
  published
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
    property Server: TCoOuterObjProperties read GetServerProperties;
{$ENDIF}
  end;

{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
// *********************************************************************//
// OLE Server Properties Proxy Class
// Server Object    : TCoOuterObj
// (This object is used by the IDE's Property Inspector to allow editing
//  of the properties of this server)
// *********************************************************************//
 TCoOuterObjProperties = class(TPersistent)
  private
    FServer:    TCoOuterObj;
    function    GetDefaultInterface: ICoOuterObj;
    constructor Create(AServer: TCoOuterObj);
  protected
  public
    property DefaultInterface: ICoOuterObj read GetDefaultInterface;
  published
  end;
{$ENDIF}


procedure Register;

implementation

uses ComObj;

class function CoCoOuterObj.Create: ICoOuterObj;
begin
  Result := CreateComObject(CLASS_CoOuterObj) as ICoOuterObj;
end;

class function CoCoOuterObj.CreateRemote(const MachineName: string): ICoOuterObj;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_CoOuterObj) as ICoOuterObj;
end;

procedure TCoOuterObj.InitServerData;
const
  CServerData: TServerData = (
    ClassID:   '{9F29D601-BDE6-431A-BC2E-2FE29EEA06FF}';
    IntfIID:   '{BB35662B-C0C9-4402-B47D-001CF8E5E099}';
    EventIID:  '';
    LicenseKey: nil;
    Version: 500);
begin
  ServerData := @CServerData;
end;

procedure TCoOuterObj.Connect;
var
  punk: IUnknown;
begin
  if FIntf = nil then
  begin
    punk := GetServer;
    Fintf:= punk as ICoOuterObj;
  end;
end;

procedure TCoOuterObj.ConnectTo(svrIntf: ICoOuterObj);
begin
  Disconnect;
  FIntf := svrIntf;
end;

procedure TCoOuterObj.DisConnect;
begin
  if Fintf <> nil then
  begin
    FIntf := nil;
  end;
end;

function TCoOuterObj.GetDefaultInterface: ICoOuterObj;
begin
  if FIntf = nil then
    Connect;
  Assert(FIntf <> nil, 'DefaultInterface is NULL. Component is not connected to Server. You must call ''Connect'' or ''ConnectTo'' before this operation');
  Result := FIntf;
end;

constructor TCoOuterObj.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  FProps := TCoOuterObjProperties.Create(Self);
{$ENDIF}
end;

destructor TCoOuterObj.Destroy;
begin
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  FProps.Free;
{$ENDIF}
  inherited Destroy;
end;

{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
function TCoOuterObj.GetServerProperties: TCoOuterObjProperties;
begin
  Result := FProps;
end;
{$ENDIF}

{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
constructor TCoOuterObjProperties.Create(AServer: TCoOuterObj);
begin
  inherited Create;
  FServer := AServer;
end;

function TCoOuterObjProperties.GetDefaultInterface: ICoOuterObj;
begin
  Result := FServer.DefaultInterface;
end;

{$ENDIF}

procedure Register;
begin
  RegisterComponents('Servers',[TCoOuterObj]);
end;

end.
