2012-04-19 243 views
0

這是C++頭文件,我想從德爾福調用一個函數:轉換C++指針代碼德爾福

* @param hConnection Handle to the connection to FM. 
* @param pOperation See description of ABS_OPERATION. 
* @param dwTemplateCount Count of templates in the pTemplateArray. 
* @param pTemplateArray Pointer to the array of pointers to templates. 
* @param pResult Pointer to memory location, where result of the comparing 
*/ 
ABS_STATUS BSAPI ABSVerify(
    IN ABS_CONNECTION hConnection, 
    IN ABS_OPERATION* pOperation, 
    IN ABS_DWORD dwTemplateCount, 
    IN ABS_BIR** pTemplateArray, 
    OUT ABS_LONG* pResult, 
    IN ABS_DWORD dwFlags 
); 

- 防守

/** 
* The header of the BIR. This type is equivalent to BioAPI's structure 
* BioAPI_BIR_HEADER. 
*/ 
typedef struct abs_bir_header { 
    ABS_DWORD Length;  ///< Length of Header + Opaque Data 
    ABS_BYTE HeaderVersion; ///< HeaderVersion = 1 
    ABS_BYTE Type; ///< Type = 4 (BioAPI_BIR_DATA_TYPE_PROCESSED) 
    ABS_WORD FormatOwner;  ///< FormatOwner = 0x12 (STMicroelectronics) 
    ABS_WORD FormatID; ///< FormatID = 0 
    ABS_CHAR Quality;  ///< Quality = -2 (BioAPI_QUALITY is not supported) 
    ABS_BYTE Purpose;  ///< Purpose (BioAPI_PURPOSE_xxxx, ABS_PURPOSE_xxxx). 
    ABS_DWORD FactorsMask; ///< FactorsMask = 0x08 (BioAPI_FACTOR_FINGERPRINT) 
} ABS_BIR_HEADER; 

/** 
* A container for biometric data. 
*/ 
typedef struct abs_bir { 
    ABS_BIR_HEADER Header; ///< BIR header 
    ABS_BYTE Data[ABS_VARLEN]; ///< The data composing the fingerprint template. 
} ABS_BIR; 

    struct abs_operation; 
typedef struct abs_operation ABS_OPERATION; /* forward declaration */ 

/** 
* A type of the callback function that an application can supply to 
* the BSAPI to enable itself to display GUI state information to user. 
* 
* @param pOperation Pointer to ABS_OPERATION structure used when calling the interactive operation. 
* @param dwMsgID ID of message. See description of ABS_MSG_xxxx constants. 
* @param pMsgData Pointer to data with additional information related with 
* the message. 
*/ 
typedef void (BSAPI *ABS_CALLBACK) (const ABS_OPERATION*, ABS_DWORD, void*); 
+0

您需要出示'ABS_OPERATION'的定義和'ABS_BIR' – 2012-04-19 21:34:58

+0

我加入了高清 – Ezi 2012-04-19 21:42:36

+1

什麼是你的問題?確保它是一般的興趣。 [Stack Overflow是不是代碼的翻譯服務。(http://meta.stackexchange.com/a/129362/33732) – 2012-04-19 21:47:20

回答

2

這可能是這樣的:

function ABSVerify(
    hConnection: Integer; 
    Operation: PABS_OPERATION; 
    dwTemplateCount: DWORD; 
    pTemplateArray: PPABS_BIR; 
    var pResult: Integer; 
    dwFlags: DWORD 
): Integer; stdcall; external 'bsapi.dll'; 

是一點點朦朧的東西是ABS_OPERATION。因爲這是一個IN參數,但它是作爲一個指針傳遞給ABS_OPERATION,我想這是一個struct。你將需要聲明一個匹配的Delphi記錄和一個指針類型。也許是這樣的:

type 
    ABS_OPERATION = record 
    field1: Integer; 
    field2: Integer; 
    //etc. 
    end; 
    PABS_OPERATION = ^ABS_OPERATION; 

需要照顧另一個參數是pTemplateArray

pTemplateArray指向指針數組模板。

這是一個指針數組。 C中的數組作爲指針傳遞給第一個元素。以便解釋的類型,ABS_BIR**,指針到第一元件,它本身就是一個指向ABS_BIR。現在

var 
    TemplateArray: array of PABS_BIR; 
... 
    SetLength(TemplateArray, dwTemplateCount); 
    // populate TemplateArray 
    returnval := ABSVerify(..., dwTemplateCount, @TemplateArray[0], ...); 

我看到你在編輯添加的結構定義:

type 
    ABS_BIR = ... //whatever it is 
    PABS_BIR = ^ABS_BIR; 
    PPABS_BIR = ^PABS_BIR; 

你可以調用該函數是這樣的。我會把我的結構留在這裏,因爲你應該能夠自己轉換這些結構。

+0

非常感謝您的努力。 – Ezi 2012-04-19 21:47:58

1

您必須檢查什麼BSAPI做出決議至。我假設stdcall

type 
    PABS_OPERATION = ^ABS_OPERATION; 
    PABS_BIR = ^ABS_BIR; 
    PPABS_BIR = ^PABS_BIR; 
    PABS_LONG = ^ABS_LONG; 

function ABSVerify( 
    hConnection: ABS_CONNECTION; 
    pOperation: PABS_OPERATION; 
    dwTemplateCount: ABS_DWORD; 
    pTemplateArray: PPABS_BIR; 
    pResult: PABS_LONG; 
    dwFlags: ABS_DWORD 
): ABS_STATUS; stdcall; 

或者:

type 
    PABS_BIR = ^ABS_BIR; 

function ABSVerify( 
    hConnection: ABS_CONNECTION; 
    var pOperation: ABS_OPERATION; 
    dwTemplateCount: ABS_DWORD; 
    var pTemplateArray: PABS_BIR; 
    out pResult: ABS_LONG; 
    dwFlags: ABS_DWORD 
): ABS_STATUS; stdcall;