After using CPort, other ComPort librarys can have problems. Could be fixed with save and restore DBC state befor and after using CPort see code below.
Gruss Heinz
const
{Heinz}CError_GetStateFailed = 24;
var
{Heinz}actualDCB: _DCB;
// create handle to serial port
procedure TCustomComPort.CreateHandle;
var
dev : String;
flags : Cardinal;
begin
dev := '\\.\' + FPort;
if FOverlapped then { This is a big change from classic TComPort }
flags := FILE_FLAG_OVERLAPPED
else
flags := 0;
FHandle := CreateFile(
PChar(dev),
GENERIC_READ or GENERIC_WRITE,
0,
nil,
OPEN_EXISTING,
flags,
0);
if FHandle = INVALID_HANDLE_VALUE then
begin
{$ifdef CPORT_CALLTRACE}
OutputDebugString(PChar('CreateHandle: CreateFile ' + dev));
{$endif}
raise EComPort.Create(CError_OpenFailed, GetLastError, FPort);
{Heinz}//end;
//Originalzustand einlesen
end else
If not GetCommState(FHandle, actualDCB) then
raise EComPort.Create(CError_GetStateFailed, GetLastError, FPort);
end;
// destroy serial port handle
procedure TCustomComPort.DestroyHandle;
begin
if FHandle <> INVALID_HANDLE_VALUE then
{Heinz}//CloseHandle(FHandle);
begin
//Originalzustand zurückschreiben
If not SetCommState(FHandle, actualDCB) then
raise EComPort.Create(CError_SetStateFailed, GetLastError, FPort);
CloseHandle(FHandle);
end;
end;