PCSGU250.dll: Problems with procedures ReadCh1 and ReadCh2

I tried to read data from the Oscilloscope using the routines ReadCh1 and ReadCh2 from the library PCSGU250.dll.
I used a Delphi-program to make the calls to the routines. But whenever the main program calls ReadCH1 or ReadCh2 it aborts with an exception message which points to the address ReadCh1 + 33. I’m using the Lazarus-IDE Version 1.6.4 for a Win32-platform.

I must admit that I am not familiar with Delphi and maybe i did something wrong. Any idea how to solve the problem?

Below, please find the code of my main program. The PCSGU250-software must be running before the program is started.
After start of the program, press e.g. the Single button in the oscilloscope window. Then, in the console wondow the message ‘Reading data from PCSGU250…’ is shown, but the message ‘Ready!’ does never appear.

program ReadDataFromPCSGU250;

uses SysUtils;

var
data1 : array[0…4999] of Integer;
p1 : Pointer;
t,t1,t2 : TDateTime;

function DataReady : Boolean; external ‘PCSGU250.DLL’;
procedure ReadCh1 (var p1 : Pointer); external ‘PCSGU250.DLL’;

procedure wait (var t : TDateTime);
begin
t1 := 86400.0Time();
t2 := t1;
while (t2-t1)<t do t2 := 86400.0
Time();
end;

begin
t := 0.01;
Writeln(‘Waiting for new data…’);
while not(DataReady()) do wait(t); // every 10 ms ask whether new data is available

Writeln(‘Reading data from PCSGU250…’);
p1 := @data1[0];
ReadCh1(p1);
Writeln(‘ready!’);

Readln;
end.

Please try with these kind of function declarations:procedure ReadCh1(Buffer: Pointer); stdcall; external 'PCSGU250.dll'; procedure ReadCh2(Buffer: Pointer); stdcall; external 'PCSGU250.dll'; function DataReady:Boolean; stdcall; external 'PCSGU250.dll';

The “var” is removed and “stdcall” is added to the declarations.

BTW: You can convert the Delphi PCSGU250 demo project to Lazarus project …
wiki.freepascal.org/Delphi_Converter_in_Lazarus

Thank you very much for the quick and helpful response.
The problem is solved now!
Both were important: Omitting the keyword var and including the attribute stdcall.