3
int  WINAPI  BiMICRSetReadBackFunction(
    int  nHandle,
    int  (CALLBACK  *pMicrCB)(void),
    LPBYTE  pReadBuffSize,
    LPBYTE  readCharBuff,
    LPBYTE  pStatus,
    LPBYTE  pDetail);

    typedef int (CALLBACK* MICRCallback)(void);
    typedef int (CALLBACK* StatusCallback)(DWORD);

    int WINAPI BiSetInkStatusBackFunction(int nHandle,
        int (CALLBACK *pStatusCB)(DWORD dwStatus)
);

我需要将此函数转换为 Delphi。

我尝试使用headconv4.2但生成的静态单元没有完成,编译时出现错误。

提前感谢您的帮助:D

4

2 回答 2

3

假设WINAPI并且CALLBACK总是存在__stdcallDWORD存在unsigned intLPBYTE作为unsigned char *,你可以试试我做的这个肮脏的转换

unit UHeader;

interface

// Data types

type
  PByte = ^Byte;
  PPByte = ^PByte;

// Prototypes

type
  TMICRCallback = function: Integer; stdcall;
  TStatusCallback = function(dwParam: Cardinal): Integer; stdcall;

// Functions

type
  TBiMICRSetReadBackFunction =
    function(nHande: Integer;
             pMicrCB: TMICRCallback;
             pReadBuffSize: PByte;
             readCharBuff: PByte;
             pStatus: PByte;
             pDetail: PByte
    ): Integer; stdcall;

var
  BiMICRSetReadBackFunction: TBiMICRSetReadBackFunction;

type
  TBiSetInkStatusBackFunction =
    function(nHandle: Integer;
             pStatusCB: TStatusCallback
    ): Integer; stdcall;

var
  BiSetInkStatusBackFunction: TBiSetInkStatusBackFunction;

implementation

end.

不过,我不完全确定这是否正确……但这可能是您尝试自己转换它的途径。

于 2012-09-26T00:29:19.127 回答
2

直译为:

type
  MICRCallback = function: Integer; stdcall; 
  StatusCallback = function(dwStatus: DWORD): Integer; stdcall; 

function BiMICRSetReadBackFunction( 
  nHandle: Integer; 
  pMicrCB: MICRCallback; 
  pReadBuffSize: PByte; 
  readCharBuff: PByte; 
  pStatus: PByte; 
  pDetail: PByte
): Integer; stdcall; 

function BiSetInkStatusBackFunction(
  nHandle: Integer;
  pStatusCB: StatusCallback
): Integer; stdcall; 

如果要从 DLL 导入函数,则需要将 DLL 文件名添加到函数声明中:

function BiMICRSetReadBackFunction( 
  nHandle: Integer; 
  pMicrCB: MICRCallback; 
  pReadBuffSize: PByte; 
  readCharBuff: PByte; 
  pStatus: PByte; 
  pDetail: PByte
): Integer; stdcall; external 'filename.dll';

function BiSetInkStatusBackFunction(
  nHandle: Integer;
  pStatusCB: StatusCallback
): Integer; stdcall; external 'filename.dll';
于 2012-09-26T01:24:03.550 回答