Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert C Header to delphi

Tags:

c

header

dll

delphi

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)
);

I need to convert this function to Delphi.

I tried to use headconv4.2 but the resulting static unit is not completed, and errors occur when compiling.

Thanks in advance for your kind help :D

like image 300
Rafael Miguel Caceres Choto Avatar asked Oct 20 '25 02:10

Rafael Miguel Caceres Choto


1 Answers

Supposing WINAPI and CALLBACK always being __stdcall, DWORD being unsigned int and LPBYTE as unsigned char *, you could try this dirty conversion I made:

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.

I'm not entirely sure, though, if this is correct... but this could be a path for you to try to convert it yourself.

like image 187
Toribio Avatar answered Oct 21 '25 15:10

Toribio