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
|