unit ACOMPORTLib_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 : 1.2
// File generated on 12/23/2006 6:28:05 PM from Type Library described below.

// ************************************************************************  //
// Type Lib: C:\Program Files\Common Files\ActiveXperts\AComPort.dll (1)
// LIBID: {68A2C188-A606-4841-AE8A-D58C6F6BE583}
// LCID: 0
// Helpfile: 
// HelpString: ActiveComport 2.2 Type Library
// DepndLst: 
//   (1) v2.0 stdole, (C:\WINDOWS\system32\stdole2.tlb)
// Errors:
//   Hint: Parameter 'String' of IComPort.WriteString changed to 'String_'
//   Hint: Parameter 'String' of IComPort.ReadString changed to 'String_'
//   Hint: Parameter 'Raise' of IComPort.RaiseRTS changed to 'Raise_'
//   Hint: Parameter 'Raise' of IComPort.RaiseDTR changed to 'Raise_'
//   Error creating palette bitmap of (TComPort) : Server C:\Program Files\Common Files\ActiveXperts\AComPort.dll contains no icons
// ************************************************************************ //
// *************************************************************************//
// 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.                                                          
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers. 
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
interface

uses Windows, ActiveX, Classes, Graphics, OleServer, StdVCL, Variants;
  

// *********************************************************************//
// 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
  ACOMPORTLibMajorVersion = 1;
  ACOMPORTLibMinorVersion = 0;

  LIBID_ACOMPORTLib: TGUID = '{68A2C188-A606-4841-AE8A-D58C6F6BE583}';

  IID_IComPort: TGUID = '{38014DE4-7967-4F71-A6C1-CDB62E7DD269}';
  CLASS_ComPort: TGUID = '{07ECB42B-322A-40B9-A8A9-3815AF3C4F60}';
type

// *********************************************************************//
// Forward declaration of types defined in TypeLibrary                    
// *********************************************************************//
  IComPort = interface;
  IComPortDisp = dispinterface;

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


// *********************************************************************//
// Interface: IComPort
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {38014DE4-7967-4F71-A6C1-CDB62E7DD269}
// *********************************************************************//
  IComPort = interface(IDispatch)
    ['{38014DE4-7967-4F71-A6C1-CDB62E7DD269}']
    function Get_PortID: Integer; safecall;
    procedure Set_PortID(PortID: Integer); safecall;
    function Get_BaudRate: Integer; safecall;
    procedure Set_BaudRate(BaudRate: Integer); safecall;
    function Get_Parity: Smallint; safecall;
    procedure Set_Parity(Parity: Smallint); safecall;
    function Get_DataBits: Smallint; safecall;
    procedure Set_DataBits(DataBits: Smallint); safecall;
    function Get_StopBits: Smallint; safecall;
    procedure Set_StopBits(StopBits: Smallint); safecall;
    function Get_HardwareFlowControl: Integer; safecall;
    procedure Set_HardwareFlowControl(HardwareFlowControl: Integer); safecall;
    function Get_SoftwareFlowControl: Integer; safecall;
    procedure Set_SoftwareFlowControl(SoftwareFlowControl: Integer); safecall;
    procedure Open; safecall;
    procedure Close; safecall;
    procedure WriteString(const String_: WideString); safecall;
    function ReadString: WideString; safecall;
    function Get_LastError: Integer; safecall;
    procedure Sleep(Millisecs: Integer); safecall;
    function Get_ComTimeout: Integer; safecall;
    procedure Set_ComTimeout(Millisecs: Integer); safecall;
    procedure ClearTX; safecall;
    procedure ClearRX; safecall;
    procedure UpdateCom; safecall;
    procedure WriteByte(Byte: Smallint); safecall;
    function Get_Version: WideString; safecall;
    function Get_ExpirationDate: WideString; safecall;
    procedure Activate(const Key: WideString); safecall;
    function Get_IsOpened: Integer; safecall;
    procedure Set_Reserved(Param1: Integer); safecall;
    function ReadByte: Smallint; safecall;
    function Get_Build: WideString; safecall;
    procedure RaiseRTS(Raise_: Integer); safecall;
    procedure RaiseDTR(Raise_: Integer); safecall;
    function QueryCTS: Integer; safecall;
    function QueryDSR: Integer; safecall;
    procedure WriteBytes(const Bytes: WideString); safecall;
    function ReadBytes: WideString; safecall;
    function GetErrorDescription(Error: Integer): WideString; safecall;
    function GetDeviceCount: Integer; safecall;
    function GetDevice(Device: Integer): WideString; safecall;
    function Get_Device: WideString; safecall;
    procedure Set_Device(const Device: WideString); safecall;
    function Get_asPARITY_NONE: Integer; safecall;
    function Get_asPARITY_ODD: Integer; safecall;
    function Get_asPARITY_EVEN: Integer; safecall;
    function Get_asPARITY_MARK: Integer; safecall;
    function Get_asPARITY_SPACE: Integer; safecall;
    function Get_asSTOPBITS_1: Integer; safecall;
    function Get_asSTOPBITS_2: Integer; safecall;
    function Get_asSTOPBITS_15: Integer; safecall;
    function QueryDCD: Integer; safecall;
    function QueryRI: Integer; safecall;
    function Get_LogFile: WideString; safecall;
    procedure Set_LogFile(const LogFile: WideString); safecall;
    function Get_RTSFlowControl: Integer; safecall;
    procedure Set_RTSFlowControl(RTSl: Integer); safecall;
    function Get_DTRFlowControl: Integer; safecall;
    procedure Set_DTRFlowControl(DTR: Integer); safecall;
    function Get_CTSFlowControl: Integer; safecall;
    procedure Set_CTSFlowControl(CTS: Integer); safecall;
    function Get_DSRFlowControl: Integer; safecall;
    procedure Set_DSRFlowControl(DSR: Integer); safecall;
    function Get_asFLOWCONTROL_DEFAULT: Integer; safecall;
    function Get_asFLOWCONTROL_DISABLE: Integer; safecall;
    function Get_asFLOWCONTROL_ENABLE: Integer; safecall;
    function Get_asPARITY_DEFAULT: Integer; safecall;
    function Get_asSTOPBITS_DEFAULT: Integer; safecall;
    function Get_asDATABITS_DEFAULT: Integer; safecall;
    function Get_asDATABITS_7: Integer; safecall;
    function Get_asDATABITS_8: Integer; safecall;
    property PortID: Integer read Get_PortID write Set_PortID;
    property BaudRate: Integer read Get_BaudRate write Set_BaudRate;
    property Parity: Smallint read Get_Parity write Set_Parity;
    property DataBits: Smallint read Get_DataBits write Set_DataBits;
    property StopBits: Smallint read Get_StopBits write Set_StopBits;
    property HardwareFlowControl: Integer read Get_HardwareFlowControl write Set_HardwareFlowControl;
    property SoftwareFlowControl: Integer read Get_SoftwareFlowControl write Set_SoftwareFlowControl;
    property LastError: Integer read Get_LastError;
    property ComTimeout: Integer read Get_ComTimeout write Set_ComTimeout;
    property Version: WideString read Get_Version;
    property ExpirationDate: WideString read Get_ExpirationDate;
    property IsOpened: Integer read Get_IsOpened;
    property Reserved: Integer write Set_Reserved;
    property Build: WideString read Get_Build;
    property Device: WideString read Get_Device write Set_Device;
    property asPARITY_NONE: Integer read Get_asPARITY_NONE;
    property asPARITY_ODD: Integer read Get_asPARITY_ODD;
    property asPARITY_EVEN: Integer read Get_asPARITY_EVEN;
    property asPARITY_MARK: Integer read Get_asPARITY_MARK;
    property asPARITY_SPACE: Integer read Get_asPARITY_SPACE;
    property asSTOPBITS_1: Integer read Get_asSTOPBITS_1;
    property asSTOPBITS_2: Integer read Get_asSTOPBITS_2;
    property asSTOPBITS_15: Integer read Get_asSTOPBITS_15;
    property LogFile: WideString read Get_LogFile write Set_LogFile;
    property RTSFlowControl: Integer read Get_RTSFlowControl write Set_RTSFlowControl;
    property DTRFlowControl: Integer read Get_DTRFlowControl write Set_DTRFlowControl;
    property CTSFlowControl: Integer read Get_CTSFlowControl write Set_CTSFlowControl;
    property DSRFlowControl: Integer read Get_DSRFlowControl write Set_DSRFlowControl;
    property asFLOWCONTROL_DEFAULT: Integer read Get_asFLOWCONTROL_DEFAULT;
    property asFLOWCONTROL_DISABLE: Integer read Get_asFLOWCONTROL_DISABLE;
    property asFLOWCONTROL_ENABLE: Integer read Get_asFLOWCONTROL_ENABLE;
    property asPARITY_DEFAULT: Integer read Get_asPARITY_DEFAULT;
    property asSTOPBITS_DEFAULT: Integer read Get_asSTOPBITS_DEFAULT;
    property asDATABITS_DEFAULT: Integer read Get_asDATABITS_DEFAULT;
    property asDATABITS_7: Integer read Get_asDATABITS_7;
    property asDATABITS_8: Integer read Get_asDATABITS_8;
  end;

// *********************************************************************//
// DispIntf:  IComPortDisp
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {38014DE4-7967-4F71-A6C1-CDB62E7DD269}
// *********************************************************************//
  IComPortDisp = dispinterface
    ['{38014DE4-7967-4F71-A6C1-CDB62E7DD269}']
    property PortID: Integer dispid 1;
    property BaudRate: Integer dispid 2;
    property Parity: Smallint dispid 3;
    property DataBits: Smallint dispid 4;
    property StopBits: Smallint dispid 5;
    property HardwareFlowControl: Integer dispid 6;
    property SoftwareFlowControl: Integer dispid 7;
    procedure Open; dispid 8;
    procedure Close; dispid 9;
    procedure WriteString(const String_: WideString); dispid 10;
    function ReadString: WideString; dispid 11;
    property LastError: Integer readonly dispid 12;
    procedure Sleep(Millisecs: Integer); dispid 13;
    property ComTimeout: Integer dispid 14;
    procedure ClearTX; dispid 15;
    procedure ClearRX; dispid 16;
    procedure UpdateCom; dispid 17;
    procedure WriteByte(Byte: Smallint); dispid 18;
    property Version: WideString readonly dispid 19;
    property ExpirationDate: WideString readonly dispid 20;
    procedure Activate(const Key: WideString); dispid 21;
    property IsOpened: Integer readonly dispid 22;
    property Reserved: Integer writeonly dispid 23;
    function ReadByte: Smallint; dispid 24;
    property Build: WideString readonly dispid 25;
    procedure RaiseRTS(Raise_: Integer); dispid 26;
    procedure RaiseDTR(Raise_: Integer); dispid 27;
    function QueryCTS: Integer; dispid 28;
    function QueryDSR: Integer; dispid 29;
    procedure WriteBytes(const Bytes: WideString); dispid 30;
    function ReadBytes: WideString; dispid 31;
    function GetErrorDescription(Error: Integer): WideString; dispid 32;
    function GetDeviceCount: Integer; dispid 33;
    function GetDevice(Device: Integer): WideString; dispid 34;
    property Device: WideString dispid 35;
    property asPARITY_NONE: Integer readonly dispid 36;
    property asPARITY_ODD: Integer readonly dispid 37;
    property asPARITY_EVEN: Integer readonly dispid 38;
    property asPARITY_MARK: Integer readonly dispid 39;
    property asPARITY_SPACE: Integer readonly dispid 40;
    property asSTOPBITS_1: Integer readonly dispid 41;
    property asSTOPBITS_2: Integer readonly dispid 42;
    property asSTOPBITS_15: Integer readonly dispid 43;
    function QueryDCD: Integer; dispid 44;
    function QueryRI: Integer; dispid 45;
    property LogFile: WideString dispid 46;
    property RTSFlowControl: Integer dispid 47;
    property DTRFlowControl: Integer dispid 48;
    property CTSFlowControl: Integer dispid 49;
    property DSRFlowControl: Integer dispid 50;
    property asFLOWCONTROL_DEFAULT: Integer readonly dispid 51;
    property asFLOWCONTROL_DISABLE: Integer readonly dispid 52;
    property asFLOWCONTROL_ENABLE: Integer readonly dispid 53;
    property asPARITY_DEFAULT: Integer readonly dispid 54;
    property asSTOPBITS_DEFAULT: Integer readonly dispid 55;
    property asDATABITS_DEFAULT: Integer readonly dispid 56;
    property asDATABITS_7: Integer readonly dispid 57;
    property asDATABITS_8: Integer readonly dispid 58;
  end;

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


// *********************************************************************//
// OLE Server Proxy class declaration
// Server Object    : TComPort
// Help String      : ComPort Class
// Default Interface: IComPort
// Def. Intf. DISP? : No
// Event   Interface: 
// TypeFlags        : (2) CanCreate
// *********************************************************************//
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  TComPortProperties= class;
{$ENDIF}
  TComPort = class(TOleServer)
  private
    FIntf:        IComPort;
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
    FProps:       TComPortProperties;
    function      GetServerProperties: TComPortProperties;
{$ENDIF}
    function      GetDefaultInterface: IComPort;
  protected
    procedure InitServerData; override;
    function Get_PortID: Integer;
    procedure Set_PortID(PortID: Integer);
    function Get_BaudRate: Integer;
    procedure Set_BaudRate(BaudRate: Integer);
    function Get_Parity: Smallint;
    procedure Set_Parity(Parity: Smallint);
    function Get_DataBits: Smallint;
    procedure Set_DataBits(DataBits: Smallint);
    function Get_StopBits: Smallint;
    procedure Set_StopBits(StopBits: Smallint);
    function Get_HardwareFlowControl: Integer;
    procedure Set_HardwareFlowControl(HardwareFlowControl: Integer);
    function Get_SoftwareFlowControl: Integer;
    procedure Set_SoftwareFlowControl(SoftwareFlowControl: Integer);
    function Get_LastError: Integer;
    function Get_ComTimeout: Integer;
    procedure Set_ComTimeout(Millisecs: Integer);
    function Get_Version: WideString;
    function Get_ExpirationDate: WideString;
    function Get_IsOpened: Integer;
    procedure Set_Reserved(Param1: Integer);
    function Get_Build: WideString;
    function Get_Device: WideString;
    procedure Set_Device(const Device: WideString);
    function Get_asPARITY_NONE: Integer;
    function Get_asPARITY_ODD: Integer;
    function Get_asPARITY_EVEN: Integer;
    function Get_asPARITY_MARK: Integer;
    function Get_asPARITY_SPACE: Integer;
    function Get_asSTOPBITS_1: Integer;
    function Get_asSTOPBITS_2: Integer;
    function Get_asSTOPBITS_15: Integer;
    function Get_LogFile: WideString;
    procedure Set_LogFile(const LogFile: WideString);
    function Get_RTSFlowControl: Integer;
    procedure Set_RTSFlowControl(RTSl: Integer);
    function Get_DTRFlowControl: Integer;
    procedure Set_DTRFlowControl(DTR: Integer);
    function Get_CTSFlowControl: Integer;
    procedure Set_CTSFlowControl(CTS: Integer);
    function Get_DSRFlowControl: Integer;
    procedure Set_DSRFlowControl(DSR: Integer);
    function Get_asFLOWCONTROL_DEFAULT: Integer;
    function Get_asFLOWCONTROL_DISABLE: Integer;
    function Get_asFLOWCONTROL_ENABLE: Integer;
    function Get_asPARITY_DEFAULT: Integer;
    function Get_asSTOPBITS_DEFAULT: Integer;
    function Get_asDATABITS_DEFAULT: Integer;
    function Get_asDATABITS_7: Integer;
    function Get_asDATABITS_8: Integer;
  public
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;
    procedure Connect; override;
    procedure ConnectTo(svrIntf: IComPort);
    procedure Disconnect; override;
    procedure Open;
    procedure Close;
    procedure WriteString(const String_: WideString);
    function ReadString: WideString;
    procedure Sleep(Millisecs: Integer);
    procedure ClearTX;
    procedure ClearRX;
    procedure UpdateCom;
    procedure WriteByte(Byte: Smallint);
    procedure Activate(const Key: WideString);
    function ReadByte: Smallint;
    procedure RaiseRTS(Raise_: Integer);
    procedure RaiseDTR(Raise_: Integer);
    function QueryCTS: Integer;
    function QueryDSR: Integer;
    procedure WriteBytes(const Bytes: WideString);
    function ReadBytes: WideString;
    function GetErrorDescription(Error: Integer): WideString;
    function GetDeviceCount: Integer;
    function GetDevice(Device: Integer): WideString;
    function QueryDCD: Integer;
    function QueryRI: Integer;
    property DefaultInterface: IComPort read GetDefaultInterface;
    property LastError: Integer read Get_LastError;
    property Version: WideString read Get_Version;
    property ExpirationDate: WideString read Get_ExpirationDate;
    property IsOpened: Integer read Get_IsOpened;
    property Reserved: Integer write Set_Reserved;
    property Build: WideString read Get_Build;
    property asPARITY_NONE: Integer read Get_asPARITY_NONE;
    property asPARITY_ODD: Integer read Get_asPARITY_ODD;
    property asPARITY_EVEN: Integer read Get_asPARITY_EVEN;
    property asPARITY_MARK: Integer read Get_asPARITY_MARK;
    property asPARITY_SPACE: Integer read Get_asPARITY_SPACE;
    property asSTOPBITS_1: Integer read Get_asSTOPBITS_1;
    property asSTOPBITS_2: Integer read Get_asSTOPBITS_2;
    property asSTOPBITS_15: Integer read Get_asSTOPBITS_15;
    property asFLOWCONTROL_DEFAULT: Integer read Get_asFLOWCONTROL_DEFAULT;
    property asFLOWCONTROL_DISABLE: Integer read Get_asFLOWCONTROL_DISABLE;
    property asFLOWCONTROL_ENABLE: Integer read Get_asFLOWCONTROL_ENABLE;
    property asPARITY_DEFAULT: Integer read Get_asPARITY_DEFAULT;
    property asSTOPBITS_DEFAULT: Integer read Get_asSTOPBITS_DEFAULT;
    property asDATABITS_DEFAULT: Integer read Get_asDATABITS_DEFAULT;
    property asDATABITS_7: Integer read Get_asDATABITS_7;
    property asDATABITS_8: Integer read Get_asDATABITS_8;
    property PortID: Integer read Get_PortID write Set_PortID;
    property BaudRate: Integer read Get_BaudRate write Set_BaudRate;
    property Parity: Smallint read Get_Parity write Set_Parity;
    property DataBits: Smallint read Get_DataBits write Set_DataBits;
    property StopBits: Smallint read Get_StopBits write Set_StopBits;
    property HardwareFlowControl: Integer read Get_HardwareFlowControl write Set_HardwareFlowControl;
    property SoftwareFlowControl: Integer read Get_SoftwareFlowControl write Set_SoftwareFlowControl;
    property ComTimeout: Integer read Get_ComTimeout write Set_ComTimeout;
    property Device: WideString read Get_Device write Set_Device;
    property LogFile: WideString read Get_LogFile write Set_LogFile;
    property RTSFlowControl: Integer read Get_RTSFlowControl write Set_RTSFlowControl;
    property DTRFlowControl: Integer read Get_DTRFlowControl write Set_DTRFlowControl;
    property CTSFlowControl: Integer read Get_CTSFlowControl write Set_CTSFlowControl;
    property DSRFlowControl: Integer read Get_DSRFlowControl write Set_DSRFlowControl;
  published
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
    property Server: TComPortProperties read GetServerProperties;
{$ENDIF}
  end;

{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
// *********************************************************************//
// OLE Server Properties Proxy Class
// Server Object    : TComPort
// (This object is used by the IDE's Property Inspector to allow editing
//  of the properties of this server)
// *********************************************************************//
 TComPortProperties = class(TPersistent)
  private
    FServer:    TComPort;
    function    GetDefaultInterface: IComPort;
    constructor Create(AServer: TComPort);
  protected
    function Get_PortID: Integer;
    procedure Set_PortID(PortID: Integer);
    function Get_BaudRate: Integer;
    procedure Set_BaudRate(BaudRate: Integer);
    function Get_Parity: Smallint;
    procedure Set_Parity(Parity: Smallint);
    function Get_DataBits: Smallint;
    procedure Set_DataBits(DataBits: Smallint);
    function Get_StopBits: Smallint;
    procedure Set_StopBits(StopBits: Smallint);
    function Get_HardwareFlowControl: Integer;
    procedure Set_HardwareFlowControl(HardwareFlowControl: Integer);
    function Get_SoftwareFlowControl: Integer;
    procedure Set_SoftwareFlowControl(SoftwareFlowControl: Integer);
    function Get_LastError: Integer;
    function Get_ComTimeout: Integer;
    procedure Set_ComTimeout(Millisecs: Integer);
    function Get_Version: WideString;
    function Get_ExpirationDate: WideString;
    function Get_IsOpened: Integer;
    procedure Set_Reserved(Param1: Integer);
    function Get_Build: WideString;
    function Get_Device: WideString;
    procedure Set_Device(const Device: WideString);
    function Get_asPARITY_NONE: Integer;
    function Get_asPARITY_ODD: Integer;
    function Get_asPARITY_EVEN: Integer;
    function Get_asPARITY_MARK: Integer;
    function Get_asPARITY_SPACE: Integer;
    function Get_asSTOPBITS_1: Integer;
    function Get_asSTOPBITS_2: Integer;
    function Get_asSTOPBITS_15: Integer;
    function Get_LogFile: WideString;
    procedure Set_LogFile(const LogFile: WideString);
    function Get_RTSFlowControl: Integer;
    procedure Set_RTSFlowControl(RTSl: Integer);
    function Get_DTRFlowControl: Integer;
    procedure Set_DTRFlowControl(DTR: Integer);
    function Get_CTSFlowControl: Integer;
    procedure Set_CTSFlowControl(CTS: Integer);
    function Get_DSRFlowControl: Integer;
    procedure Set_DSRFlowControl(DSR: Integer);
    function Get_asFLOWCONTROL_DEFAULT: Integer;
    function Get_asFLOWCONTROL_DISABLE: Integer;
    function Get_asFLOWCONTROL_ENABLE: Integer;
    function Get_asPARITY_DEFAULT: Integer;
    function Get_asSTOPBITS_DEFAULT: Integer;
    function Get_asDATABITS_DEFAULT: Integer;
    function Get_asDATABITS_7: Integer;
    function Get_asDATABITS_8: Integer;
  public
    property DefaultInterface: IComPort read GetDefaultInterface;
  published
    property PortID: Integer read Get_PortID write Set_PortID;
    property BaudRate: Integer read Get_BaudRate write Set_BaudRate;
    property Parity: Smallint read Get_Parity write Set_Parity;
    property DataBits: Smallint read Get_DataBits write Set_DataBits;
    property StopBits: Smallint read Get_StopBits write Set_StopBits;
    property HardwareFlowControl: Integer read Get_HardwareFlowControl write Set_HardwareFlowControl;
    property SoftwareFlowControl: Integer read Get_SoftwareFlowControl write Set_SoftwareFlowControl;
    property ComTimeout: Integer read Get_ComTimeout write Set_ComTimeout;
    property Device: WideString read Get_Device write Set_Device;
    property LogFile: WideString read Get_LogFile write Set_LogFile;
    property RTSFlowControl: Integer read Get_RTSFlowControl write Set_RTSFlowControl;
    property DTRFlowControl: Integer read Get_DTRFlowControl write Set_DTRFlowControl;
    property CTSFlowControl: Integer read Get_CTSFlowControl write Set_CTSFlowControl;
    property DSRFlowControl: Integer read Get_DSRFlowControl write Set_DSRFlowControl;
  end;
{$ENDIF}


procedure Register;

resourcestring
  dtlServerPage = 'ActiveX';

  dtlOcxPage = 'ActiveX';

implementation

uses ComObj;

class function CoComPort.Create: IComPort;
begin
  Result := CreateComObject(CLASS_ComPort) as IComPort;
end;

class function CoComPort.CreateRemote(const MachineName: string): IComPort;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_ComPort) as IComPort;
end;

procedure TComPort.InitServerData;
const
  CServerData: TServerData = (
    ClassID:   '{07ECB42B-322A-40B9-A8A9-3815AF3C4F60}';
    IntfIID:   '{38014DE4-7967-4F71-A6C1-CDB62E7DD269}';
    EventIID:  '';
    LicenseKey: nil;
    Version: 500);
begin
  ServerData := @CServerData;
end;

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

procedure TComPort.ConnectTo(svrIntf: IComPort);
begin
  Disconnect;
  FIntf := svrIntf;
end;

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

function TComPort.GetDefaultInterface: IComPort;
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 TComPort.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
{$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  FProps := TComPortProperties.Create(Self);
{$ENDIF}
end;

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

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

function TComPort.Get_PortID: Integer;
begin
    Result := DefaultInterface.PortID;
end;

procedure TComPort.Set_PortID(PortID: Integer);
begin
  DefaultInterface.Set_PortID(PortID);
end;

function TComPort.Get_BaudRate: Integer;
begin
    Result := DefaultInterface.BaudRate;
end;

procedure TComPort.Set_BaudRate(BaudRate: Integer);
begin
  DefaultInterface.Set_BaudRate(BaudRate);
end;

function TComPort.Get_Parity: Smallint;
begin
    Result := DefaultInterface.Parity;
end;

procedure TComPort.Set_Parity(Parity: Smallint);
begin
  DefaultInterface.Set_Parity(Parity);
end;

function TComPort.Get_DataBits: Smallint;
begin
    Result := DefaultInterface.DataBits;
end;

procedure TComPort.Set_DataBits(DataBits: Smallint);
begin
  DefaultInterface.Set_DataBits(DataBits);
end;

function TComPort.Get_StopBits: Smallint;
begin
    Result := DefaultInterface.StopBits;
end;

procedure TComPort.Set_StopBits(StopBits: Smallint);
begin
  DefaultInterface.Set_StopBits(StopBits);
end;

function TComPort.Get_HardwareFlowControl: Integer;
begin
    Result := DefaultInterface.HardwareFlowControl;
end;

procedure TComPort.Set_HardwareFlowControl(HardwareFlowControl: Integer);
begin
  DefaultInterface.Set_HardwareFlowControl(HardwareFlowControl);
end;

function TComPort.Get_SoftwareFlowControl: Integer;
begin
    Result := DefaultInterface.SoftwareFlowControl;
end;

procedure TComPort.Set_SoftwareFlowControl(SoftwareFlowControl: Integer);
begin
  DefaultInterface.Set_SoftwareFlowControl(SoftwareFlowControl);
end;

function TComPort.Get_LastError: Integer;
begin
    Result := DefaultInterface.LastError;
end;

function TComPort.Get_ComTimeout: Integer;
begin
    Result := DefaultInterface.ComTimeout;
end;

procedure TComPort.Set_ComTimeout(Millisecs: Integer);
begin
  DefaultInterface.Set_ComTimeout(Millisecs);
end;

function TComPort.Get_Version: WideString;
begin
    Result := DefaultInterface.Version;
end;

function TComPort.Get_ExpirationDate: WideString;
begin
    Result := DefaultInterface.ExpirationDate;
end;

function TComPort.Get_IsOpened: Integer;
begin
    Result := DefaultInterface.IsOpened;
end;

procedure TComPort.Set_Reserved(Param1: Integer);
begin
  DefaultInterface.Set_Reserved(Param1);
end;

function TComPort.Get_Build: WideString;
begin
    Result := DefaultInterface.Build;
end;

function TComPort.Get_Device: WideString;
begin
    Result := DefaultInterface.Device;
end;

procedure TComPort.Set_Device(const Device: WideString);
  { Warning: The property Device has a setter and a getter whose
    types do not match. Delphi was unable to generate a property of
    this sort and so is using a Variant as a passthrough. }
var
  InterfaceVariant: OleVariant;
begin
  InterfaceVariant := DefaultInterface;
  InterfaceVariant.Device := Device;
end;

function TComPort.Get_asPARITY_NONE: Integer;
begin
    Result := DefaultInterface.asPARITY_NONE;
end;

function TComPort.Get_asPARITY_ODD: Integer;
begin
    Result := DefaultInterface.asPARITY_ODD;
end;

function TComPort.Get_asPARITY_EVEN: Integer;
begin
    Result := DefaultInterface.asPARITY_EVEN;
end;

function TComPort.Get_asPARITY_MARK: Integer;
begin
    Result := DefaultInterface.asPARITY_MARK;
end;

function TComPort.Get_asPARITY_SPACE: Integer;
begin
    Result := DefaultInterface.asPARITY_SPACE;
end;

function TComPort.Get_asSTOPBITS_1: Integer;
begin
    Result := DefaultInterface.asSTOPBITS_1;
end;

function TComPort.Get_asSTOPBITS_2: Integer;
begin
    Result := DefaultInterface.asSTOPBITS_2;
end;

function TComPort.Get_asSTOPBITS_15: Integer;
begin
    Result := DefaultInterface.asSTOPBITS_15;
end;

function TComPort.Get_LogFile: WideString;
begin
    Result := DefaultInterface.LogFile;
end;

procedure TComPort.Set_LogFile(const LogFile: WideString);
  { Warning: The property LogFile has a setter and a getter whose
    types do not match. Delphi was unable to generate a property of
    this sort and so is using a Variant as a passthrough. }
var
  InterfaceVariant: OleVariant;
begin
  InterfaceVariant := DefaultInterface;
  InterfaceVariant.LogFile := LogFile;
end;

function TComPort.Get_RTSFlowControl: Integer;
begin
    Result := DefaultInterface.RTSFlowControl;
end;

procedure TComPort.Set_RTSFlowControl(RTSl: Integer);
begin
  DefaultInterface.Set_RTSFlowControl(RTSl);
end;

function TComPort.Get_DTRFlowControl: Integer;
begin
    Result := DefaultInterface.DTRFlowControl;
end;

procedure TComPort.Set_DTRFlowControl(DTR: Integer);
begin
  DefaultInterface.Set_DTRFlowControl(DTR);
end;

function TComPort.Get_CTSFlowControl: Integer;
begin
    Result := DefaultInterface.CTSFlowControl;
end;

procedure TComPort.Set_CTSFlowControl(CTS: Integer);
begin
  DefaultInterface.Set_CTSFlowControl(CTS);
end;

function TComPort.Get_DSRFlowControl: Integer;
begin
    Result := DefaultInterface.DSRFlowControl;
end;

procedure TComPort.Set_DSRFlowControl(DSR: Integer);
begin
  DefaultInterface.Set_DSRFlowControl(DSR);
end;

function TComPort.Get_asFLOWCONTROL_DEFAULT: Integer;
begin
    Result := DefaultInterface.asFLOWCONTROL_DEFAULT;
end;

function TComPort.Get_asFLOWCONTROL_DISABLE: Integer;
begin
    Result := DefaultInterface.asFLOWCONTROL_DISABLE;
end;

function TComPort.Get_asFLOWCONTROL_ENABLE: Integer;
begin
    Result := DefaultInterface.asFLOWCONTROL_ENABLE;
end;

function TComPort.Get_asPARITY_DEFAULT: Integer;
begin
    Result := DefaultInterface.asPARITY_DEFAULT;
end;

function TComPort.Get_asSTOPBITS_DEFAULT: Integer;
begin
    Result := DefaultInterface.asSTOPBITS_DEFAULT;
end;

function TComPort.Get_asDATABITS_DEFAULT: Integer;
begin
    Result := DefaultInterface.asDATABITS_DEFAULT;
end;

function TComPort.Get_asDATABITS_7: Integer;
begin
    Result := DefaultInterface.asDATABITS_7;
end;

function TComPort.Get_asDATABITS_8: Integer;
begin
    Result := DefaultInterface.asDATABITS_8;
end;

procedure TComPort.Open;
begin
  DefaultInterface.Open;
end;

procedure TComPort.Close;
begin
  DefaultInterface.Close;
end;

procedure TComPort.WriteString(const String_: WideString);
begin
  DefaultInterface.WriteString(String_);
end;

function TComPort.ReadString: WideString;
begin
  Result := DefaultInterface.ReadString;
end;

procedure TComPort.Sleep(Millisecs: Integer);
begin
  DefaultInterface.Sleep(Millisecs);
end;

procedure TComPort.ClearTX;
begin
  DefaultInterface.ClearTX;
end;

procedure TComPort.ClearRX;
begin
  DefaultInterface.ClearRX;
end;

procedure TComPort.UpdateCom;
begin
  DefaultInterface.UpdateCom;
end;

procedure TComPort.WriteByte(Byte: Smallint);
begin
  DefaultInterface.WriteByte(Byte);
end;

procedure TComPort.Activate(const Key: WideString);
begin
  DefaultInterface.Activate(Key);
end;

function TComPort.ReadByte: Smallint;
begin
  Result := DefaultInterface.ReadByte;
end;

procedure TComPort.RaiseRTS(Raise_: Integer);
begin
  DefaultInterface.RaiseRTS(Raise_);
end;

procedure TComPort.RaiseDTR(Raise_: Integer);
begin
  DefaultInterface.RaiseDTR(Raise_);
end;

function TComPort.QueryCTS: Integer;
begin
  Result := DefaultInterface.QueryCTS;
end;

function TComPort.QueryDSR: Integer;
begin
  Result := DefaultInterface.QueryDSR;
end;

procedure TComPort.WriteBytes(const Bytes: WideString);
begin
  DefaultInterface.WriteBytes(Bytes);
end;

function TComPort.ReadBytes: WideString;
begin
  Result := DefaultInterface.ReadBytes;
end;

function TComPort.GetErrorDescription(Error: Integer): WideString;
begin
  Result := DefaultInterface.GetErrorDescription(Error);
end;

function TComPort.GetDeviceCount: Integer;
begin
  Result := DefaultInterface.GetDeviceCount;
end;

function TComPort.GetDevice(Device: Integer): WideString;
begin
  Result := DefaultInterface.GetDevice(Device);
end;

function TComPort.QueryDCD: Integer;
begin
  Result := DefaultInterface.QueryDCD;
end;

function TComPort.QueryRI: Integer;
begin
  Result := DefaultInterface.QueryRI;
end;

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

function TComPortProperties.GetDefaultInterface: IComPort;
begin
  Result := FServer.DefaultInterface;
end;

function TComPortProperties.Get_PortID: Integer;
begin
    Result := DefaultInterface.PortID;
end;

procedure TComPortProperties.Set_PortID(PortID: Integer);
begin
  DefaultInterface.Set_PortID(PortID);
end;

function TComPortProperties.Get_BaudRate: Integer;
begin
    Result := DefaultInterface.BaudRate;
end;

procedure TComPortProperties.Set_BaudRate(BaudRate: Integer);
begin
  DefaultInterface.Set_BaudRate(BaudRate);
end;

function TComPortProperties.Get_Parity: Smallint;
begin
    Result := DefaultInterface.Parity;
end;

procedure TComPortProperties.Set_Parity(Parity: Smallint);
begin
  DefaultInterface.Set_Parity(Parity);
end;

function TComPortProperties.Get_DataBits: Smallint;
begin
    Result := DefaultInterface.DataBits;
end;

procedure TComPortProperties.Set_DataBits(DataBits: Smallint);
begin
  DefaultInterface.Set_DataBits(DataBits);
end;

function TComPortProperties.Get_StopBits: Smallint;
begin
    Result := DefaultInterface.StopBits;
end;

procedure TComPortProperties.Set_StopBits(StopBits: Smallint);
begin
  DefaultInterface.Set_StopBits(StopBits);
end;

function TComPortProperties.Get_HardwareFlowControl: Integer;
begin
    Result := DefaultInterface.HardwareFlowControl;
end;

procedure TComPortProperties.Set_HardwareFlowControl(HardwareFlowControl: Integer);
begin
  DefaultInterface.Set_HardwareFlowControl(HardwareFlowControl);
end;

function TComPortProperties.Get_SoftwareFlowControl: Integer;
begin
    Result := DefaultInterface.SoftwareFlowControl;
end;

procedure TComPortProperties.Set_SoftwareFlowControl(SoftwareFlowControl: Integer);
begin
  DefaultInterface.Set_SoftwareFlowControl(SoftwareFlowControl);
end;

function TComPortProperties.Get_LastError: Integer;
begin
    Result := DefaultInterface.LastError;
end;

function TComPortProperties.Get_ComTimeout: Integer;
begin
    Result := DefaultInterface.ComTimeout;
end;

procedure TComPortProperties.Set_ComTimeout(Millisecs: Integer);
begin
  DefaultInterface.Set_ComTimeout(Millisecs);
end;

function TComPortProperties.Get_Version: WideString;
begin
    Result := DefaultInterface.Version;
end;

function TComPortProperties.Get_ExpirationDate: WideString;
begin
    Result := DefaultInterface.ExpirationDate;
end;

function TComPortProperties.Get_IsOpened: Integer;
begin
    Result := DefaultInterface.IsOpened;
end;

procedure TComPortProperties.Set_Reserved(Param1: Integer);
begin
  DefaultInterface.Set_Reserved(Param1);
end;

function TComPortProperties.Get_Build: WideString;
begin
    Result := DefaultInterface.Build;
end;

function TComPortProperties.Get_Device: WideString;
begin
    Result := DefaultInterface.Device;
end;

procedure TComPortProperties.Set_Device(const Device: WideString);
  { Warning: The property Device has a setter and a getter whose
    types do not match. Delphi was unable to generate a property of
    this sort and so is using a Variant as a passthrough. }
var
  InterfaceVariant: OleVariant;
begin
  InterfaceVariant := DefaultInterface;
  InterfaceVariant.Device := Device;
end;

function TComPortProperties.Get_asPARITY_NONE: Integer;
begin
    Result := DefaultInterface.asPARITY_NONE;
end;

function TComPortProperties.Get_asPARITY_ODD: Integer;
begin
    Result := DefaultInterface.asPARITY_ODD;
end;

function TComPortProperties.Get_asPARITY_EVEN: Integer;
begin
    Result := DefaultInterface.asPARITY_EVEN;
end;

function TComPortProperties.Get_asPARITY_MARK: Integer;
begin
    Result := DefaultInterface.asPARITY_MARK;
end;

function TComPortProperties.Get_asPARITY_SPACE: Integer;
begin
    Result := DefaultInterface.asPARITY_SPACE;
end;

function TComPortProperties.Get_asSTOPBITS_1: Integer;
begin
    Result := DefaultInterface.asSTOPBITS_1;
end;

function TComPortProperties.Get_asSTOPBITS_2: Integer;
begin
    Result := DefaultInterface.asSTOPBITS_2;
end;

function TComPortProperties.Get_asSTOPBITS_15: Integer;
begin
    Result := DefaultInterface.asSTOPBITS_15;
end;

function TComPortProperties.Get_LogFile: WideString;
begin
    Result := DefaultInterface.LogFile;
end;

procedure TComPortProperties.Set_LogFile(const LogFile: WideString);
  { Warning: The property LogFile has a setter and a getter whose
    types do not match. Delphi was unable to generate a property of
    this sort and so is using a Variant as a passthrough. }
var
  InterfaceVariant: OleVariant;
begin
  InterfaceVariant := DefaultInterface;
  InterfaceVariant.LogFile := LogFile;
end;

function TComPortProperties.Get_RTSFlowControl: Integer;
begin
    Result := DefaultInterface.RTSFlowControl;
end;

procedure TComPortProperties.Set_RTSFlowControl(RTSl: Integer);
begin
  DefaultInterface.Set_RTSFlowControl(RTSl);
end;

function TComPortProperties.Get_DTRFlowControl: Integer;
begin
    Result := DefaultInterface.DTRFlowControl;
end;

procedure TComPortProperties.Set_DTRFlowControl(DTR: Integer);
begin
  DefaultInterface.Set_DTRFlowControl(DTR);
end;

function TComPortProperties.Get_CTSFlowControl: Integer;
begin
    Result := DefaultInterface.CTSFlowControl;
end;

procedure TComPortProperties.Set_CTSFlowControl(CTS: Integer);
begin
  DefaultInterface.Set_CTSFlowControl(CTS);
end;

function TComPortProperties.Get_DSRFlowControl: Integer;
begin
    Result := DefaultInterface.DSRFlowControl;
end;

procedure TComPortProperties.Set_DSRFlowControl(DSR: Integer);
begin
  DefaultInterface.Set_DSRFlowControl(DSR);
end;

function TComPortProperties.Get_asFLOWCONTROL_DEFAULT: Integer;
begin
    Result := DefaultInterface.asFLOWCONTROL_DEFAULT;
end;

function TComPortProperties.Get_asFLOWCONTROL_DISABLE: Integer;
begin
    Result := DefaultInterface.asFLOWCONTROL_DISABLE;
end;

function TComPortProperties.Get_asFLOWCONTROL_ENABLE: Integer;
begin
    Result := DefaultInterface.asFLOWCONTROL_ENABLE;
end;

function TComPortProperties.Get_asPARITY_DEFAULT: Integer;
begin
    Result := DefaultInterface.asPARITY_DEFAULT;
end;

function TComPortProperties.Get_asSTOPBITS_DEFAULT: Integer;
begin
    Result := DefaultInterface.asSTOPBITS_DEFAULT;
end;

function TComPortProperties.Get_asDATABITS_DEFAULT: Integer;
begin
    Result := DefaultInterface.asDATABITS_DEFAULT;
end;

function TComPortProperties.Get_asDATABITS_7: Integer;
begin
    Result := DefaultInterface.asDATABITS_7;
end;

function TComPortProperties.Get_asDATABITS_8: Integer;
begin
    Result := DefaultInterface.asDATABITS_8;
end;

{$ENDIF}

procedure Register;
begin
  RegisterComponents(dtlServerPage, [TComPort]);
end;

end.
