⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 srv_tlb.pas

📁 《Delphi开发人员指南》配书原码
💻 PAS
字号:
unit Srv_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 10/28/99 1:55:17 PM 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: C:\work\d5dg\code\Ch23\Automate\Srv.tlb (1)
// IID\LCID: {B43DD7DB-21F8-4244-A494-C4793366691B}\0
// Helpfile:
// DepndLst:
//   (1) v2.0 stdole, (C:\WINDOWS\SYSTEM\STDOLE2.TLB)
//   (2) v4.0 StdVCL, (C:\WINDOWS\SYSTEM\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
  SrvMajorVersion = 1;
  SrvMinorVersion = 0;

  LIBID_Srv: TGUID = '{B43DD7DB-21F8-4244-A494-C4793366691B}';

  IID_IAutoTest: TGUID = '{C16B6A4C-842C-417F-8BF2-2F306F6C6B59}';
  CLASS_AutoTest: TGUID = '{64C576F0-C9A7-420A-9EAB-0BE98264BC9D}';

// *********************************************************************//
// Declaration of Enumerations defined in Type Library
// *********************************************************************//
// Constants for enum TxShapeType
type
  TxShapeType = TOleEnum;
const
  stRectangle = $00000000;
  stSquare = $00000001;
  stRoundRect = $00000002;
  stRoundSquare = $00000003;
  stEllipse = $00000004;
  stCircle = $00000005;

type

// *********************************************************************//
// Forward declaration of types defined in TypeLibrary
// *********************************************************************//
  IAutoTest = interface;
  IAutoTestDisp = dispinterface;

// *********************************************************************//
// Declaration of CoClasses defined in Type Library
// (NOTE: Here we map each CoClass to its Default Interface)
// *********************************************************************//
  AutoTest = IAutoTest;


// *********************************************************************//
// Interface: IAutoTest
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {C16B6A4C-842C-417F-8BF2-2F306F6C6B59}
// *********************************************************************//
  IAutoTest = interface(IDispatch)
    ['{C16B6A4C-842C-417F-8BF2-2F306F6C6B59}']
    function  Get_EditText: WideString; safecall;
    procedure Set_EditText(const Value: WideString); safecall;
    function  Get_ShapeColor: OLE_COLOR; safecall;
    procedure Set_ShapeColor(Value: OLE_COLOR); safecall;
    function  Get_ShapeType: TxShapeType; safecall;
    procedure Set_ShapeType(Value: TxShapeType); safecall;
    procedure ShowInfo; safecall;
    property EditText: WideString read Get_EditText write Set_EditText;
    property ShapeColor: OLE_COLOR read Get_ShapeColor write
      Set_ShapeColor;
    property ShapeType: TxShapeType read Get_ShapeType write
      Set_ShapeType;
  end;

// *********************************************************************//
// DispIntf:  IAutoTestDisp
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {C16B6A4C-842C-417F-8BF2-2F306F6C6B59}
// *********************************************************************//
  IAutoTestDisp = dispinterface
    ['{C16B6A4C-842C-417F-8BF2-2F306F6C6B59}']
    property EditText: WideString dispid 1;
    property ShapeColor: OLE_COLOR dispid 2;
    property ShapeType: TxShapeType dispid 3;
    procedure ShowInfo; dispid 4;
  end;

// *********************************************************************//
// The Class CoAutoTest provides a Create and CreateRemote method to          
// create instances of the default interface IAutoTest exposed by              
// the CoClass AutoTest. The functions are intended to be used by             
// clients wishing to automate the CoClass objects exposed by the         
// server of this typelibrary.                                            
// *********************************************************************//
  CoAutoTest = class
    class function Create: IAutoTest;
    class function CreateRemote(const MachineName: string): IAutoTest;
  end;


// *********************************************************************//
// OLE Server Proxy class declaration
// Server Object    : TAutoTest
// Help String      : AutoTest Object
// Default Interface: IAutoTest
// Def. Intf. DISP? : No
// Event   Interface: 
// TypeFlags        : (2) CanCreate
// *********************************************************************//
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  TAutoTestProperties= class;
{$ENDIF}
  TAutoTest = class(TOleServer)
  private
    FIntf:        IAutoTest;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
    FProps:       TAutoTestProperties;
    function      GetServerProperties: TAutoTestProperties;
{$ENDIF}
    function      GetDefaultInterface: IAutoTest;
  protected
    procedure InitServerData; override;
    function  Get_EditText: WideString;
    procedure Set_EditText(const Value: WideString);
    function  Get_ShapeColor: OLE_COLOR;
    procedure Set_ShapeColor(Value: OLE_COLOR);
    function  Get_ShapeType: TxShapeType;
    procedure Set_ShapeType(Value: TxShapeType);
  public
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;
    procedure Connect; override;
    procedure ConnectTo(svrIntf: IAutoTest);
    procedure Disconnect; override;
    procedure ShowInfo;
    property  DefaultInterface: IAutoTest read GetDefaultInterface;
    property EditText: WideString read Get_EditText write Set_EditText;
    property ShapeColor: OLE_COLOR read Get_ShapeColor write
      Set_ShapeColor;
    property ShapeType: TxShapeType read Get_ShapeType write
      Set_ShapeType;
  published
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
    property Server: TAutoTestProperties read GetServerProperties;
{$ENDIF}
  end;

{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
// *********************************************************************//
// OLE Server Properties Proxy Class
// Server Object    : TAutoTest
// (This object is used by the IDE's Property Inspector to allow editing
//  of the properties of this server)
// *********************************************************************//
 TAutoTestProperties = class(TPersistent)
  private
    FServer:    TAutoTest;
    function    GetDefaultInterface: IAutoTest;
    constructor Create(AServer: TAutoTest);
  protected
    function  Get_EditText: WideString;
    procedure Set_EditText(const Value: WideString);
    function  Get_ShapeColor: OLE_COLOR;
    procedure Set_ShapeColor(Value: OLE_COLOR);
    function  Get_ShapeType: TxShapeType;
    procedure Set_ShapeType(Value: TxShapeType);
  public
    property DefaultInterface: IAutoTest read GetDefaultInterface;
  published
    property EditText: WideString read Get_EditText write Set_EditText;
    property ShapeColor: OLE_COLOR read Get_ShapeColor write
      Set_ShapeColor;
    property ShapeType: TxShapeType read Get_ShapeType write
      Set_ShapeType;
  end;
{$ENDIF}


procedure Register;

implementation

uses ComObj;

class function CoAutoTest.Create: IAutoTest;
begin
  Result := CreateComObject(CLASS_AutoTest) as IAutoTest;
end;

class function CoAutoTest.CreateRemote(const MachineName: string):
  IAutoTest;
begin
Result := CreateRemoteComObject(MachineName, CLASS_AutoTest) as IAutoTest;
end;

procedure TAutoTest.InitServerData;
const
  CServerData: TServerData = (
    ClassID:   '{64C576F0-C9A7-420A-9EAB-0BE98264BC9D}';
    IntfIID:   '{C16B6A4C-842C-417F-8BF2-2F306F6C6B59}';
    EventIID:  '';
    LicenseKey: nil;
    Version: 500);
begin
  ServerData := @CServerData;
end;

procedure TAutoTest.Connect;
var
  punk: IUnknown;
begin
  if FIntf = nil then
  begin
    punk := GetServer;
    Fintf:= punk as IAutoTest;
  end;
end;

procedure TAutoTest.ConnectTo(svrIntf: IAutoTest);
begin
  Disconnect;
  FIntf := svrIntf;
end;

procedure TAutoTest.DisConnect;
begin
  if Fintf <> nil then
  begin
    FIntf := nil;
  end;
end;

function TAutoTest.GetDefaultInterface: IAutoTest;
const
  ErrStr = 'DefaultInterface is NULL. Component is not connected to ' +
    'Server. You must call ''Connect'' or ''ConnectTo'' before this ' +
    'operation';
begin
  if FIntf = nil then
    Connect;
  Assert(FIntf <> nil, ErrStr);
  Result := FIntf;
end;

constructor TAutoTest.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  FProps := TAutoTestProperties.Create(Self);
{$ENDIF}
end;

destructor TAutoTest.Destroy;
begin
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  FProps.Free;
{$ENDIF}
  inherited Destroy;
end;

{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
function TAutoTest.GetServerProperties: TAutoTestProperties;
begin
  Result := FProps;
end;
{$ENDIF}

function  TAutoTest.Get_EditText: WideString;
begin
  Result := DefaultInterface.Get_EditText;
end;

procedure TAutoTest.Set_EditText(const Value: WideString);
begin
  DefaultInterface.Set_EditText(Value);
end;

function  TAutoTest.Get_ShapeColor: OLE_COLOR;
begin
  Result := DefaultInterface.Get_ShapeColor;
end;

procedure TAutoTest.Set_ShapeColor(Value: OLE_COLOR);
begin
  DefaultInterface.Set_ShapeColor(Value);
end;

function  TAutoTest.Get_ShapeType: TxShapeType;
begin
  Result := DefaultInterface.Get_ShapeType;
end;

procedure TAutoTest.Set_ShapeType(Value: TxShapeType);
begin
  DefaultInterface.Set_ShapeType(Value);
end;

procedure TAutoTest.ShowInfo;
begin
  DefaultInterface.ShowInfo;
end;

{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
constructor TAutoTestProperties.Create(AServer: TAutoTest);
begin
  inherited Create;
  FServer := AServer;
end;

function TAutoTestProperties.GetDefaultInterface: IAutoTest;
begin
  Result := FServer.DefaultInterface;
end;

function  TAutoTestProperties.Get_EditText: WideString;
begin
  Result := DefaultInterface.Get_EditText;
end;

procedure TAutoTestProperties.Set_EditText(const Value: WideString);
begin
  DefaultInterface.Set_EditText(Value);
end;

function  TAutoTestProperties.Get_ShapeColor: OLE_COLOR;
begin
  Result := DefaultInterface.Get_ShapeColor;
end;

procedure TAutoTestProperties.Set_ShapeColor(Value: OLE_COLOR);
begin
  DefaultInterface.Set_ShapeColor(Value);
end;

function  TAutoTestProperties.Get_ShapeType: TxShapeType;
begin
  Result := DefaultInterface.Get_ShapeType;
end;

procedure TAutoTestProperties.Set_ShapeType(Value: TxShapeType);
begin
  DefaultInterface.Set_ShapeType(Value);
end;

{$ENDIF}

procedure Register;
begin
  RegisterComponents('Servers',[TAutoTest]);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -