home *** CD-ROM | disk | FTP | other *** search
/ Kompuutteri K-CD 2002 #1 / K-CD_2002-01.iso / Delphi / INSTALL / program files / Borland / Delphi6 / Doc / OleServer.int < prev    next >
Encoding:
Text File  |  2001-05-22  |  3.8 KB  |  101 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Borland Delphi Visual Component Library         }
  5. {                                                       }
  6. {  Copyright (c) 1999-2001 Borland Software Corporation }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit OleServer;
  11.  
  12. {$R-}
  13. {$WARN SYMBOL_PLATFORM OFF}
  14.  
  15. interface
  16.  
  17. uses Windows, Messages, ActiveX, SysUtils, Classes, ComObj;
  18.  
  19. type
  20.   TVariantArray = Array of OleVariant;
  21.   TOleServer    = class;
  22.   TConnectKind  = (ckRunningOrNew,          // Attach to a running or create a new instance of the server
  23.                    ckNewInstance,           // Create a new instance of the server
  24.                    ckRunningInstance,       // Attach to a running instance of the server
  25.                    ckRemote,                // Bind to a remote instance of the server
  26.                    ckAttachToInterface);    // Don't bind to server, user will provide interface via 'CpnnectTo'
  27.  
  28.   TServerEventDispatch = class(TObject, IUnknown, IDispatch)
  29.   protected
  30.     { IUnknown }
  31.     function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
  32.     function _AddRef: Integer; stdcall;
  33.     function _Release: Integer; stdcall;
  34.     { IDispatch }
  35.     function GetTypeInfoCount(out Count: Integer): HResult; stdcall;
  36.     function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; stdcall;
  37.     function GetIDsOfNames(const IID: TGUID; Names: Pointer;
  38.       NameCount, LocaleID: Integer; DispIDs: Pointer): HResult; stdcall;
  39.     function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
  40.       Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;
  41.     property Server: TOleServer;
  42.     function ServerDisconnect :Boolean;
  43.   public
  44.     constructor Create(Server: TOleServer);
  45.   end;
  46.  
  47.   PServerData = ^TServerData;
  48.   TServerData = record
  49.     ClassID: TGUID;                   // CLSID of CoClass
  50.     IntfIID: TGUID;                   // IID of default interface
  51.     EventIID: TGUID;                  // IID of default source interface
  52.     LicenseKey: Pointer;              // Pointer to license string (not implemented)
  53.     Version: Integer;                 // Version of this structure
  54.     InstanceCount: Integer;           // Instance of the Server running
  55.   end;
  56.  
  57.   TOleServer = class(TComponent, IUnknown)
  58.   protected
  59.       { IUnknown }
  60.     function QueryInterface(const IID: TGUID; out Obj): HResult; override;
  61.     function _AddRef: Integer; stdcall;
  62.     function _Release: Integer; stdcall;
  63.  
  64.     procedure Loaded; override;
  65.     procedure InitServerData; virtual; abstract;
  66.  
  67.     function  GetServer: IUnknown; virtual;
  68.  
  69.     procedure ConnectEvents(const Obj: IUnknown);
  70.     procedure DisconnectEvents(const Obj: Iunknown);
  71.     procedure InvokeEvent(DispID: TDispID; var Params: TVariantArray); virtual;
  72.  
  73.     function  GetConnectKind: TConnectKind;
  74.     procedure SetConnectKind(ck: TConnectKind);
  75.  
  76.     function  GetAutoConnect: Boolean;
  77.     procedure SetAutoConnect(flag: Boolean);
  78.  
  79.     property  ServerData: PServerData;
  80.     property  EventDispatch: TServerEventDispatch;
  81.  
  82.   public
  83.     constructor Create(AOwner: TComponent); override;
  84.     destructor Destroy; override;
  85.  
  86.     // NOTE: If derived class is generated by TLIBIMP or ImportTypeLibraryCodeGenerator,
  87.     //       the derived class will also expose a 'ConnectTo(interface)' function.
  88.     //       You must invoke that method if you're using 'ckAttachToInterface' connection
  89.     //       kind.
  90.     procedure Connect; virtual; abstract;
  91.     procedure Disconnect; virtual; abstract;
  92.  
  93.   published
  94.     property AutoConnect: Boolean;
  95.     property ConnectKind: TConnectKind;
  96.     property RemoteMachineName: string;
  97.   end;
  98.  
  99.  
  100. implementation
  101.