• Viernes 3 de Mayo de 2024, 02:59

Autor Tema:  Comunicacion A Puerto.  (Leído 1756 veces)

Tomy

  • Nuevo Miembro
  • *
  • Mensajes: 6
    • Ver Perfil
Comunicacion A Puerto.
« en: Jueves 26 de Febrero de 2004, 21:25 »
0
Hola:

Necesito saber como enviar y recibir datos del puerto paralelo, de forma que uno de esos datos recibidos pueda hacer que se ejecute una aplicacion.

Atte.

Tomm           :unsure:

lasiaman

  • Nuevo Miembro
  • *
  • Mensajes: 1
    • Ver Perfil
Re: Comunicacion A Puerto.
« Respuesta #1 en: Lunes 8 de Marzo de 2004, 19:00 »
0
Hola, Tomy, te paso la implementacion de un DLL que esta dando vultas por internet para poder comunicarte ya sea leeer o escribir en el puerto paralelo.
La DLL se llama IO.DLL, si no la encontrar mandame un mail y te pa paso..

unit IOPort;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

procedure PortOut(Port: Integer; Bit : Byte);   stdcall
procedure PortWordOut(Port: Integer; Data: Integer);   stdcall
procedure PortDWordOut(Port: Integer; Data: Integer);   stdcall
function PortIn(Port: Integer): Byte;   stdcall
function PortWordIn(Port: Integer): Integer;   stdcall
function PortDWordIn(Port: Integer): Integer;   stdcall
procedure SetPortBit(Port: Integer; Bit : Byte);  stdcall
procedure ClrPortBit(Port: Integer; Bit : Byte);   stdcall
procedure NotPortBit(Port: Integer; Bit : Byte);   stdcall
function GetPortBit(Port: Integer; Bit : Byte): Boolean;   stdcall
function RightPortShift(Port: Integer; Val: Boolean): Boolean;   stdcall
function LeftPortShift(Port: Integer; Val: Boolean): Boolean;   stdcall
function IsDriverInstalled: Boolean; stdcall;

type
  TIOPort = class(TComponent)
  private
  protected
  public
    Constructor Create(Owner:TComponent); Override;
    Destructor Destroy; Override;
    procedure PortOut_(Port: Integer; Bit : Byte);
    procedure PortWordOut_(Port: Integer; Data: Integer);
    procedure PortDWordOut_(Port: Integer; Data: Integer);
    function PortIn_(Port: Integer): Byte;
    function PortWordIn_(Port: Integer): Integer;
    function PortDWordIn_(Port: Integer): Integer;
    procedure SetPortBit_(Port: Integer; Bit : Byte);
    procedure ClrPortBit_(Port: Integer; Bit : Byte);
    procedure NotPortBit_(Port: Integer; Bit : Byte);
    function GetPortBit_(Port: Integer; Bit : Byte): Boolean;
    function RightPortShift_(Port: Integer; Val: Boolean): Boolean;
    function LeftPortShift_(Port: Integer; Val: Boolean): Boolean;
    function IsDriverInstalled_: Boolean;
  published
  end;

procedure Register;

implementation

procedure PortOut; external 'IO.DLL' name 'PortOut';
procedure PortWordOut; external 'IO.DLL' name 'PortWordOut';
procedure PortDWordOut; external 'IO.DLL' name 'PortDWordOut';
function PortIn; external 'IO.DLL' name 'PortIn';
function PortWordIn; external 'IO.DLL' name 'PortWordIn';
function PortDWordIn; external 'IO.DLL' name 'PortDWordIn';
procedure SetPortBit; external 'IO.DLL' name 'SetPortBit';
procedure ClrPortBit; external 'IO.DLL' name 'ClrPortBit';
procedure NotPortBit; external 'IO.DLL' name 'NotPortBit';
function GetPortBit; external 'IO.DLL' name 'GetPortBit';
function RightPortShift; external 'IO.DLL' name 'RightPortShift';
function LeftPortShift; external 'IO.DLL' name 'LeftPortShift';
function IsDriverInstalled; external 'IO.DLL' name 'IsDriverInstalled';

constructor TIOPort.Create(Owner:TComponent);
Begin
  inherited Create(Owner);
end;

destructor TIOPort.Destroy;
begin
  inherited Destroy;
end;

procedure Register;
begin
  RegisterComponents('Funcional', [TIOPort]);
end;

procedure TIOPort.PortOut_(Port: Integer; Bit : Byte);
begin
  PortOut(Port, Bit);
end;

procedure TIOPort.ClrPortBit_(Port: Integer; Bit: Byte);
begin
  ClrPortBit(Port, Bit);
end;

function TIOPort.GetPortBit_(Port: Integer; Bit: Byte): Boolean;
begin
  result := GetPortBit(Port, Bit);
end;

function TIOPort.IsDriverInstalled_: Boolean;
begin
  result := IsDriverInstalled;
end;

function TIOPort.LeftPortShift_(Port: Integer; Val: Boolean): Boolean;
begin
  result := LeftPortShift(Port, Val);
end;

procedure TIOPort.NotPortBit_(Port: Integer; Bit: Byte);
begin
  NotPortBit(Port, Bit);
end;

function TIOPort.PortDWordIn_(Port: Integer): Integer;
begin
  result := PortDWordIn(Port);
end;

procedure TIOPort.PortDWordOut_(Port, Data: Integer);
begin
  PortDWordOut(Port, Data);
end;

function TIOPort.PortIn_(Port: Integer): Byte;
begin
  result := PortIn(Port);
end;

function TIOPort.PortWordIn_(Port: Integer): Integer;
begin
  result := PortWordIn(Port);
end;

procedure TIOPort.PortWordOut_(Port, Data: Integer);
begin
  PortWordOut(Port, Data);
end;

function TIOPort.RightPortShift_(Port: Integer; Val: Boolean): Boolean;
begin
  result := RightPortShift(Port, Val);
end;

procedure TIOPort.SetPortBit_(Port: Integer; Bit: Byte);
begin
  SetPortBit(Port, Bit);
end;


end.