I'm trying to read the return of an access to the COM3 port, which is where the old 56kbps modem is.
The communication is being made and the modem is getting and receiving calls from outside!
But I would like to read the data that the modem can send me.
The connection to the modem port did so:
...
hCommFile: THandle;
Status: LongBool;
NumberWritten: DWORD;
Buf : array[0..1023] of Byte;
s :string;
.......
//Abre a porta de comunicação
s:='COM3';
hCommFile := CreateFile (
PChar(s),
GENERIC_READ or GENERIC_WRITE,
0, // não compartilhado
nil, // sem segurança
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
0);
// Verifica a abertura da porta
if hCommFile <> INVALID_HANDLE_VALUE then
begin
//Envia a String de Comando
NumberWritten:=0;
Status:= WriteFile(
hCommFile,
PChar(s)[0],
Length(s),
NumberWritten,
nil);
...
So far so good.
But I'm trying to get data from the modems.
I think I need to use the class inputStream
but I do not think anything for Delphi .
I tried this way but the code crashed
if FileRead(hCommFile, Buf[0], 1023) = 1 then
begin
ShowMessage('a');
end;
....
Someone helps.
The goal is to get a return only and play on a variable!