Aplication crash in Delphi 2009 after ps3000_open_unit()

Post general discussions on using our drivers to write your own software here
Post Reply
Guest

Aplication crash in Delphi 2009 after ps3000_open_unit()

Post by Guest »

Hi

I am developing an application in Delphi 2009 using a PS3425. The problem is that the application crashes after ps3000_open_unit() no matter which ps3000_x function I call. Function call ps3000_open_unit() works fine and the unit opens (value > 0 returned).

Example:

handle := ps3000_open_unit();
ps3000_flash_led(handle); = CRASH

and

handle := ps3000_open_unit();
ps3000_close_unit(handle); = CRASH

Because the supplied Delphi project is not compiling in Delphi 2009 I am unable to use the project. Therefore I have created my own project and DO NOT use ps3000.inc (which does not compile). Therefore I have declared the prototypes to the functions I use.

function ps3000_open_unit(): smallint; external 'ps3000.dll';
function ps3000_close_unit(handle : smallint): smallint; external 'ps3000.dll';
function ps3000_flash_led(handle : smallint) : smallint; external 'ps3000.dll';

The function prototypes are included just after the "implementation" tag (correct ?).
I think the crashes has something to do with the function protoypes but I dont know what or why. Can somebody help me?

Guest

Solution found!

Post by Guest »

Hi again :-)

I've just found a solution to my problem.

The solution was a missing "stdcall;" to every function prototype. The function prototypes should look like this:

function ps3000_open_unit(): smallint; stdcall; external 'ps3000.dll';
function ps3000_close_unit(handle : smallint): smallint; stdcall; external 'ps3000.dll';
function ps3000_flash_led(handle : smallint) : smallint; stdcall; external 'ps3000.dll';
function ps3000_stop(handle : smallint): smallint; stdcall; external 'ps3000.dll';

with the "stdcall;" included before the "external" tag. I was unaware of that was necessary . But now I know :-)

Cheers,
Ulrik

Post Reply