Access to memory error!

Asked

Viewed 78 times

2

I’m trying to implement a BINA with Delphi 7 using Super Bina!

I added the component to form and in a botão done:

procedure TfrmPrincipal.btnAbreConClick(Sender: TObject);
var
  texto: String;
begin
  spBina.Conectado:=true;
  spBina.LeiaDTMF(texto,100);
  ShowMessage(texto);
end;

and in the onDTMF done

procedure TfrmPrincipal.spBinaDTMF(Sender: TObject; Count: Integer);
var
  Buffer : String;
  Contador: Integer;
begin

  // Define o valor do Time Out
  Sleep(500);
  // Confere o número total de bytes dentro do pacote enviado
  Contador := spBina.InputCount;
  // Lê o pacote enviado e armazena no Buffer
  spBina.Read(Buffer, Contador);
  // Alimenta um campo Memo com os dados recebidos
  Memo1.Lines.Add(Buffer);
end;

So, in the code of botão, when the ring of telephone line i get RING in the ShowMessage. That’s all! in the code of onDTMF, on arrival spBina.Read(Buffer, Contador);, is giving access to memory!

How to fix this?

// Ler no modo sincrono
function TSspBina.ReadAsync(var Buffer; Count: Integer; var AsyncPtr: PAsync): Integer;
var
  Success: Boolean;
  BytesTrans: DWORD;
begin
  AsyncPtr^.Kind := okRead;
  Success := ReadFile(FHandle, Buffer, Count, BytesTrans, @AsyncPtr^.Overlapped)
    or (GetLastError = ERROR_IO_PENDING);

  if not Success then
    raise ECspBina.Create(CError_ReadFailed, GetLastError);

  Result := BytesTrans;
end;

when it does the ReadFile

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.