Delphi how to call c++ dll function with typedef void * parameter?

Viewed 1952

I have a dll that is written in C. My delphi wrapper is calling functions from c++ dll.

This is C++ code:

typedef enum EFTDeviceControlAction
{
        EFT_DCA_CR_CARD_RETRACT = 0x01,
        EFT_DCA_CR_CARD_REPOSITION = 0x02,
        EFT_DCA_CR_SHUTTER_OPEN = 0x03,
        EFT_DCA_CR_SHUTTER_CLOSE = 0x04,
        EFT_DCA_CR_CARD_EJECT = 0x05,
}

typedef enum EFT_PrintOptions {
        poPrintState = 0,
        poPrintFirst = 1,
        poPrintSubsequent = 2,
        poPrintFinal = 3,
        poPrintAbort = 9
} EFT_PrintOptions;


typedef void * EFT_HANDLE;

int EFT_CreateSession(EFT_HANDLE * h);
int EFT_DestroySession(EFT_HANDLE h);
int EFT_ReadProperty(EFT_HANDLE h, int table, int index, char * pValue, unsigned int maxLength);
int EFT_WriteProperty(EFT_HANDLE h, int table, int index, char * pValue);
...

And this is delphi code :

EFTDeviceControlAction = (
        EFT_DCA_CR_CARD_RETRACT = $01,
        EFT_DCA_CR_CARD_REPOSITION = $02,
        EFT_DCA_CR_SHUTTER_OPEN = $03,
        EFT_DCA_CR_SHUTTER_CLOSE = $04,
        EFT_DCA_CR_CARD_EJECT = $05,
);

EFT_PrintOptions = (
        poPrintState = 0,
        poPrintFirst = 1,
        poPrintSubsequent = 2,
        poPrintFinal = 3,
        poPrintAbort = 9
);

EFT_HANDLE = pointer;

function EFT_CreateSession(var h: EFT_HANDLE): Integer; stdcall; external 'api.dll';
function EFT_DestroySession(h: EFT_HANDLE): Integer; stdcall; external 'api.dll';
function EFT_ReadProperty(h: EFT_HANDLE; table: Integer; index: Integer; pValue: PChar; maxLength: Cardinal): Integer; stdcall; external 'api.dll';
function EFT_WriteProperty(h: EFT_HANDLE; table: Integer; index: Integer; pValue: PChar): Integer; stdcall; external 'api.dll';

Problem that I have is the line (C++)

typedef void * EFT_HANDLE 

How is this line defined in Delphi? Is this a pointer, procedure ??? and what value do I use for parameter when I call function?

For every call I get Access violation at address 0040537B in module

1 Answers
Related