unit Data;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
PortIO, Async32;
type
TDataModule2 =
class(TDataModule)
Comm1: TComm;
DLPortIO1: TDLPortIO;
procedure DataModule2Create(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
procedure HandleException(Sender: TObject; E:
Exception);
end;
var
DataModule2: TDataModule2;
implementation
{$R *.DFM}
{$HINTS OFF}
procedure TDataModule2.DataModule2Create(Sender: TObject);
var
s:
String;
e:
Exception;
begin
GetDir(0,s);
DLPortIO1.DLLPath := s + '
\';
DLPortIO1.DriverPath := s + '
\';
DLPortIO1.OpenDriver;
if (
not DLPortIO1.ActiveHW)
then
begin
MessageDlg('
RS232 Treiber konnten nicht geladen werden!', mtError, [mbOK], 0);
end;
DLPortIO1.Port[$378 + 2] := DLPortIO1.Port[$378 + 2]
Or $20;
Application.OnException := HandleException;
Comm1.BaudRate := cbr9600;
Comm1.Databits := da8;
Comm1.Parity := paNone;
Comm1.Stopbits := sb10;
Comm1.DeviceName := '
Com1';
TRY
Comm1.Open;
MessageDlg('
VB OK - '+ GetProviderSubtypeName(Comm1.ProviderSubtype), mtInformation, [mbOK] ,0);
EXCEPT
on E: ECommError
do showmessage(e.
message);
END;
end;
{$HINTS ON}
procedure TDataModule2.HandleException(Sender: TObject; E:
Exception);
begin
if E
is ECommError
then
with E
as ECommError
do
ShowMessage('
Async32 error: ' +
Message);
end;
end.