Delphi-Quellcode:
unit EDEComPort;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, Dialogs;
const
DefaultComPort = '
Com1';
DefaultDataBits = 8;
DefaultStopBits = 1;
DefaultParity = '
none';
type
TEDEComPort =
class(TComponent)
private
{ Private-Deklarationen }
VComPort:
String;
VParity:
String;
VDataBits: Integer;
VStopBits: Integer;
procedure SetComPort(Value:
String);
procedure SetParity(Value:
String);
procedure SetDatabits(Value: Integer);
procedure SetStopbits(Value: Integer);
protected
{ Protected-Deklarationen }
public
{ Public-Deklarationen }
constructor Create;
override;
//<- Dekleration "Create" unterscheidet sich von vorheriger Dekleration
function Open : Boolean;
function Close : Boolean;
procedure TX(Data:
String);
function RX :
String;
property ComPort:
String read VComPort
write SetComPort;
property Parity:
String read VParity
write SetParity;
property Databits: Integer
read VDatabits
write SetDatabits
default DefaultDatabits;
property Stopbits: Integer
read VStopbits
write SetStopbits
default DefaultStopbits;
published
{ Published-Deklarationen }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('
Tobias Hocke Software', [TEDEComPort]);
end;
constructor TEDEComPort.Create;
begin
inherited Create;
//<- Nicht genügend wirkliche Parameter
ComPort := DefaultComPort;
end;
Schaut euch mal den Code an