Return to KLUBNL.PL main page

[Top] [All Lists]

Re: LF: VERY TECHNICAL: Comports and Delphi

To: [email protected]
Subject: Re: LF: VERY TECHNICAL: Comports and Delphi
From: "Alberto di Bene" <[email protected]>
Date: Wed, 11 Apr 2001 15:17:41 +0200
Organization: Undisclosed
References: <[email protected]>
Reply-to: [email protected]
Sender: <[email protected]>
john sexton wrote:

Hi fellow programmers,
Sorry to use the reflector for this purpose, but I know there are a lot of
Delphi programmers out there.
Can anyone tell me how to read from the COM1 port using Delphi and 32-bit
Windows? It has got to be simple, but I just can't find it amongst the
mountain of information. Regrettably C++ answers won't help.
Many thanks in advance,
John, G4CNN

Hi John,
              my suggestion is language-independent.
Check the Windows APIs  CreateFile,  GetCommModemStatus
and ReadFileEx.
Using CreateFile you specify COM1 as file name and get in return a handle.
Then you call GetCommModemStatus with this handle, and you have
in return the status of CTS, DTR, etc. if this is what you want to do.
If instead you want to read the actual data present on COM1, you use
the ReadFileEx, again using the handle returned by the CreateFile.

Using Windows API will guarantee you (within limits...) that your program
will survive a Windows version upgrade.

73  Alberto  I2PHD

<Prev in Thread] Current Thread [Next in Thread>