我是 delphi 的新手,我在 delphi 中开发的程序与在 C++ 中开发的 dll 一起工作,我需要使用抛出访问冲突地址异常的指针函数,经过多次测试,我不知道如何解决它。
这是delphi中指针函数的定义,从头文件c ++开始翻译
type
TMICRCallback = function: Integer of Object; stdcall;
TStatusCallback = function(dwParam: Cardinal): Integer of Object; stdcall;
type
TBiMICRSetReadBackFunction =
function(const nHande: Integer;
pMicrCB: TMICRCallback;
var pReadBuffSize: Byte;
var readCharBuff: Byte;
var pStatus: Byte;
var pDetail: Byte
): Integer; stdcall;
var
BiMICRSetReadBackFunction: TBiMICRSetReadBackFunction;
type
TBiMICRSetReadBackFunction =
function(const nHande: Integer;
pMicrCB: TMICRCallback;
var pReadBuffSize: Byte;
var readCharBuff: Byte;
var pStatus: Byte;
var pDetail: Byte
): Integer; stdcall;
var
BiMICRSetReadBackFunction: TBiMICRSetReadBackFunction;
这是调用指针函数的代码
type
function CBMICRRead : Integer; stdcall;
function CBMICRStatus(dwStatus: LongWord) : Integer; stdcall;
Respuesta : TMICRCallback;
Estado : TStatusCallback;
BiSetStatusBackFunction(m_hApi, Estado);
BiMICRSetReadBackFunction (m_hApi,
Respuesta,
m_MICRReadBuffSize,
m_MICRReadBuff[0],
m_MICRReadStatus,
m_MICRReadStDetail);
这是接口的 C++ 端:
typedef int (CALLBACK* MICRCallback)(void);
typedef int (CALLBACK* StatusCallback)(DWORD);
int WINAPI BiSetStatusBackFunction(int nHandle,
int (CALLBACK *pStatusCB)(DWORD dwStatus));
int WINAPI BiMICRSetReadBackFunction(int nHandle,
int (CALLBACK *pMicrCB)(void),
LPBYTE pReadBuffSize,
LPBYTE readCharBuff,
LPBYTE pStatus,
LPBYTE pDetail);