unit xObj;

////////////////////////////////////////////////////////////////////////////////////////////////////
//        (    ,  )   //
////////////////////////////////////////////////////////////////////////////////////////////////////

interface

uses
  // VCL
  SysUtils, ActiveX;

type

  TObjX = class
  private
    fControlInterface: Variant;
  public
    constructor Create;
    destructor Destroy; override;
  public
    property ControlInterface: Variant read fControlInterface;
  end;

implementation

uses
  untUtil, ComObj;

constructor TObjX.Create;

  function Register_DLL(var Value: Variant): Boolean;
  begin
    while VarEquals(Value, Unassigned) do
    begin
      try
        Value := CreateOleObject('AddIn.RcpPrn51');
      except
        Value := Unassigned;
      end;
      if VarEquals(Value, Unassigned) then
        if (RegisterDriver('RcpPrn1C.dll') in [rrCancel]) then Break;
    end;
    Result := not VarEquals(Value, Unassigned);
  end;

begin
  inherited Create;
  if not Register_DLL(fControlInterface) then raise Exception.Create('  ');
end;

destructor TObjX.Destroy;
begin
  fControlInterface := Unassigned;
  inherited Destroy;
end;

end.
