Convert Header C / C ++ to Delphi

1

The intention is to consume a biometrics dll link

I thought the best way would be to convert the headers that they provide (not a good idea). There are 3 headers:

  • VrBio.h
  • VTypes.h
  • VConsts.h

So far I've been able to convert (I think) VConsts.h and VTypes.h. But I stopped in a function that has a statement of a pointer pointer pointer (I think that's it) that I do not know with is in delphi: VListDevices(const char*** devices,int *N) .

What I've been able to do so far is this:

unit Veridis.Biometric;

interface

uses
  Windows;

const
  {VrBio_FingerQuality}
    FINGER_QUALITY_UNKNOWN   = 0; {Unknown fingerprint quality}
    FINGER_QUALITY_VERY_LOW  = 1; {Very low fingerprint quality}
    FINGER_QUALITY_LOW       = 2; {Low fingerprint quality}
    FINGER_QUALITY_MEDIUM    = 3; {Medium fingerprint quality}
    FINGER_QUALITY_HIGH      = 4; {High fingerprint quality}
    FINGER_QUALITY_VERY_HIGH = 5; {Very high fingerprint quality}

  {VrBio_CompressionRate}
    COMPRESSION_RATE_LOW     = 5;  {Low compression rate (Higher quality)}
    COMPRESSION_RATE_DEFAULT = 15; {Default compression rate}
    COMPRESSION_RATE_HIGH    = 25; {High compression rate (Lower quality)}

  {VrBio_ISO197944FingerPosition}
    ISO19794_4_POSITION_UNKNOWN            = 0;  {Unknown finger}
    ISO19794_4_POSITION_RIGHT_THUMB        = 1;  {Right thumb}
    ISO19794_4_POSITION_RIGHT_INDEX        = 2;  {Right index}
    ISO19794_4_POSITION_RIGHT_MIDDLE       = 3;  {Right middle}
    ISO19794_4_POSITION_RIGHT_RING         = 4;  {Right ring}
    ISO19794_4_POSITION_RIGHT_LITTLE       = 5;  {Right little}
    ISO19794_4_POSITION_LEFT_THUMB         = 6;  {Left thumb}
    ISO19794_4_POSITION_LEFT_INDEX         = 7;  {Left index}
    ISO19794_4_POSITION_LEFT_MIDDLE        = 8;  {Left middle}
    ISO19794_4_POSITION_LEFT_RING          = 9;  {Left ring}
    ISO19794_4_POSITION_LEFT_LITTLE        = 10; {Left little}
    ISO19794_4_POSITION_RIGHT_FOUR         = 11; {Right four}
    ISO19794_4_POSITION_LEFT_FOUR          = 12; {Left four}
    ISO19794_4_POSITION_2_THUMBS           = 13; {Two thumbs}
  ISO19794_4_POSITION_UNKNOWN_PALM       = 20, {Unknown palm}
    ISO19794_4_POSITION_RIGHT_FULL_PALM    = 21; {Right full palm}
    ISO19794_4_POSITION_RIGHT_WRITERS_PALM = 22; {Rigth writers palm}
    ISO19794_4_POSITION_LEFT_FULL_PALM     = 23; {Left full palm}
    ISO19794_4_POSITION_LEFT_WRITERS_PALM  = 24; {Left writers palm}
  ISO19794_4_POSITION_RIGHT_LOWER_PALM   = 25; {Right lower palm}
    ISO19794_4_POSITION_RIGHT_UPPER_PALM   = 26; {Right upper palm}
    ISO19794_4_POSITION_LEFT_LOWER_PALM    = 27; {Left lower palm}
  ISO19794_4_POSITION_LEFT_UPPER_PALM    = 28; {Left upper palm}
  ISO19794_4_POSITION_RIGHT_OTHER        = 29; {Right other}
  ISO19794_4_POSITION_LEFT_OTHER         = 30; {Left other}
  ISO19794_4_POSITION_RIGHT_INTERDIGITAL = 31; {Right interdigital}
  ISO19794_4_POSITION_RIGHT_THENAR       = 32; {Right thenar}
  ISO19794_4_POSITION_RIGHT_HYPOTHENAR   = 33; {Right hypothenar}
    ISO19794_4_POSITION_LEFT_INTERDIGITAL  = 34; {Left interdigital}
    ISO19794_4_POSITION_LEFT_THENAR        = 35; {Left thenar}
    ISO19794_4_POSITION_LEFT_HYPOTHENAR    = 36; {Left hypothenar}

  {VrBio_EventType}

  CAPTURE_EVENT_UNPLUG                  = $001; {Fingerprint scanner unplugged from the computer.}
  CAPTURE_EVENT_PLUG                    = $002; {Fingerprint scanner plugged on the computer.}
  CAPTURE_EVENT_REMOVED                 = $004; {Finger removed from the fingerprint scanner.}
  CAPTURE_EVENT_PLACED                  = $008; {Finger placed on the fingerprint scanner.}
  CAPTURE_EVENT_IMAGE_FRAME             = $10;  {A fingerprint frame was captured on the fingerprint scanner.}
  CAPTURE_EVENT_IMAGE_CAPTURED          = $020; {A fingerprint image was captured on the fingerprint scanner.}
  CAPTURE_EVENT_USER_REMOVE             = $040; {(OBSOLETE)}
  CAPTURE_EVENT_PLUG_FINISHED           = $080; {(OBSOLETE)}
  CAPTURE_EVENT_SUN_REFLECTION_DETECTED = $100; {(OBSOLETE)}
  CAPTURE_EVENT_SUN_REFLECTION_REMOVED  = $200; {(OBSOLETE)}
  CAPTURE_EVENT_FAKE_FINGER_DETECTED    = $400; {A false finger has been detected on the sensor}
  CAPTURE_EVENT_FAKE_FINGER_REMOVED     = $800; {A false finger has been removed from the sensor}

  {Return codes.}

  SUCCESS                              = 0;   {Success}
  ERROR_FAIL                           = -1;  {Unknown or internal error}
  ERROR_ARGUMENT                       = -2;  {An invalid argument was supplied to the method}
  ERROR_ALREADY_STARTED                = -3;  {The SDK or the fingerprint reader is already started. This happens if the function \ref VStartSDK/\ref VStartReader is called more than once without calling \ref VStopSDK/\ref VStopReader}
  ERROR_NOT_STARTED                    = -4;  {The SDK was not started. Use \ref VStartSDK}
  ERROR_TIMEOUT                        = -5;  {Returner by \ref VSyncCapture when time is out}
  ERROR_ALREADY_PLUGGED                = -6;  {Fingerprint scanner already started. (OBSOLETE)}
  ERROR_NOT_PLUGGED                    = -7;  {Fingerprint reader not started. (OBSOLETE)}
  ERROR_UNSUPPORTED_OPERATION          = -8;  {The requested operation is not supported}
  ERROR_UNSUPPORTED_FORMAT             = -9;  {The template or image format supplied is not supported}
  ERROR_UNSUPPORTED_BIOMETRIC_MODALITY = -10; {Invalid biometric modality}
  ERROR_INVALID_TEMPLATE               = -11; {Invalid template}
  ERROR_NOT_LICENSED                   = -12; {The SDK was not licensed properly. Use \ref VInstallLicense}
  ERROR_FEATURE_NOT_LICENSED           = -13; {The feature is not supported for the installed license. (OBSOLETE) }
  ERROR_INVALID_LICENSE                = -14; {Invalid License - Invalid Product Key or corrupted license file }
  ERROR_LICENSE_EXPIRED                = -15; {Expired license. }
  ERROR_LICENSE_USERS_EXCEEDED         = -16; {Not used in this version of the SDK.}
  ERROR_HTTP_CONNECTION_FAIL           = -17; {It was not possible to reach the license server}
  ERROR_NOT_AVAILABLE_ON_FREE_EDITION  = -18; {Feature not supported on the free edition of the SDK. (OBSOLETE) }
  IMAGE_CONVERTER_FAIL                             = -19; { Internal error during image convertion}
  IMAGE_CONVERTER_SAME_FORMAT                  = -20; {The imageFormat of the biometricImage are the same for the input and output image}
  IMAGE_CONVERTER_INVALID_PARAMETER      = -21; {Invalid parameter}
  IMAGE_CONVERTER_INSUFFICIENT_MEMORY    = -22; { Insufficient memory}
  IMAGE_CONVERTER_INVALID_FORMAT             = -23; {Invalid image format. Check \ref VrBio_ImageFormat}
  ERROR_FILE_OPEN                                = -24; {The library could not open the file}
  ERROR_INVALID_READER_NAME              = -25; {Invalid reader name}
  ERROR_NOT_SUPPORTED                        = -26; { Not supported}
  ERROR_NESTED_CALL                            = -27; { Methods called on the same thread}
  ERROR_EXTERNAL_MEMORY                    = -28; {Memory was not allocated by the library}

  VRBIO_DLL = 'Veridis.Biometric.dll';
type
{ Biometric modality. @see VrBio_BiometricImage }
  TBiometricModality = (
    BIOMETRIC_MODALITY_UNKNOWN,     {Unknown biometric modality}
    BIOMETRIC_MODALITY_FINGERPRINT, {Fingerprint biometric modality}
    BIOMETRIC_MODALITY_FACE,        {Facial biometric modality}
    BIOMETRIC_MODALITY_VEINS,       {Veins biometric modality}
    BIOMETRIC_MODALITY_IRIS);       {Iris biometric modality}

{ Fingerprint image quality. @see VrBio_BiometricImage }
  TFingerQuality = DWORD;

{ Image compression rate. @see VrBio_BiometricImage }
  TCompressionRate = DWORD;

{ Compression mode of ISO 19794-4 image. @see VrBio_ISO197944Parameters }
  TISO197944CompressionMode = (
    ISO19794_4_COMPRESSION_NONE,        {No compression}
    ISO19794_4_COMPRESSION_NONE_PACKED, {No compression but packed}
    ISO19794_4_COMPRESSION_WSQ,         {WSQ compression}
    ISO19794_4_COMPRESSION_JPEG,        {JPEG compression}
    ISO19794_4_COMPRESSION_JPEG2000,    {JPEG2000 compression}
    ISO19794_4_COMPRESSION_PNG);        {PNG compression}

{ Impression type of ISO 19794-4 image. @see VrBio_ISO197944Parameters}
  TISO197944ImpressionType = (
    ISO19794_4_IMPRESSION_TYPE_LIVESCAN_PLAIN,        {Live captured plain impression}
    ISO19794_4_IMPRESSION_TYPE_LIVESCAN_ROLLED,       {Live captured rolled impression}
    ISO19794_4_IMPRESSION_TYPE_NONLIVESCAN_PLAIN,     {Non live (paper) captured plain impression}
    ISO19794_4_IMPRESSION_TYPE_NONLIVESCAN_ROLLED,    {Non live (paper) captured rolled impression}
    ISO19794_4_IMPRESSION_TYPE_LATENT,                {Crime scene type impression}
    ISO19794_4_IMPRESSION_TYPE_SWIPE,                 {Swipe impression}
    ISO19794_4_IMPRESSION_TYPE_LIVESCAN_CONTACTLESS); {Contactless impression type}

{ Finger position of ISO 19794-4 image. @see VrBio_ISO197944Parameters }
  TISO197944FingerPosition = DWORD;

{ Format of the fingerprint image buffer. @see VrBio_BiometricImage }
  TImageFormat = (
    IMAGEFORMAT_UNKNOWN,    {Unknown image format}
    IMAGEFORMAT_RAW,        {Raw image format}
    IMAGEFORMAT_BMP,        {Bitmap image format}
    IMAGEFORMAT_WSQ,        {WSQ image format}
    IMAGEFORMAT_ISO19794_4, {ISO 19794-4 image format}
    IMAGEFORMAT_JPEG,       {JPEG image format}
    IMAGEFORMAT_TIFF,       {TIFF image format}
    IMAGEFORMAT_PNG,        {PNG image format}
    IMAGEFORMAT_GIF);       {GIF image format}

{ Template formats. }
  TTemplateFormat = (
    TEMPLATEFORMAT_UNKNOWN,     {Unknown template format}
    TEMPLATEFORMAT_VERIDIS,     {Veridis propietary template format}
    TEMPLATEFORMAT_ISO,         {ISO 19794-2 template format}
    TEMPLATEFORMAT_ANSI,        {ANSI 378-2004 template format}
    TEMPLATEFORMAT_XYT_BOZORTH, {Bozorth xyt template format (OSBOLETE)}
    TEMPLATEFORMAT_BASE16,      {BASE 16 encoded template}
    TEMPLATEFORMAT_BASE64,      {BASE 64 encoded template}
    TEMPLATEFORMAT_JSON);       {JSON encoded template}

{ Types of fingerprint readers. @see VrBio_BiometricImage }
  TScannerType = (
    SCANNER_TYPE_UNKNOWN, {Unknown fingerprint reader type}
    SCANNER_TYPE_PHOTO,   {Slap fingerprint reader type}
    SCANNER_TYPE_ROLLED,  {Rolled fingerprint reader type}
    SCANNER_TYPE_SWIPE);  {Swipe fingerprint reader type}

{ Capture type. @see VrBio_CaptureParameters }
  TCaptureType = (
    CAPTURE_TYPE_SLAP,          {Slap capture}
    CAPTURE_TYPE_ROLLED,        {Rolled capture}
    CAPTURE_TYPE_TWO_FINGERS,   {Two fingers capture}
    CAPTURE_TYPE_FOUR_FINGERS); {Four fingers capture}

{ Events received in the callback function. @see VrBio_CaptureEventCallback }
  TEventType = DWORD;

{ Return codes. }
  TErrorCodes = DWORD;

{ (OBSOLETE) @see VGetReaderProperties }
  TReaderProperty = (
    CAPTURE_READER_FRIENDLY_NAME,
    CAPTURE_READER_VENDOR,
    CAPTURE_READER_PRODUCT,
    CAPTURE_READER_SERIAL,
    CAPTURE_READER_ADDRESS,
    CAPTURE_READER_VERSION,
    CAPTURE_READER_HARDWARE_VERSION,
    CAPTURE_READER_FIRMWARE_VERSION,
    CAPTURE_READER_SOFTWARE_VERSION);

{ @see VGetLicenseText }
  TLicenseProperty = (
    LICENSE_FULL_TEXT, {Full text. Can be used for offline licensing. }
    LICENSE_KEY,       {License key. Used for online activation. }
    LICENSE_TEXT,      {License text. }
    LICENSE_USER);     {License owner.}

{ Stores the fingerprint reader metadata. @see VGetReaderProperties @see VrBio_ReaderProperty }
  PReaderProperties = ^TReaderProperties;
  TReaderProperties = record
    uniqueName: PChar;   { Unique identifier. This is the same name returned in the @see VrBio_CaptureEventCallback parameter readerName. Supported in all readers. }
    friendlyName: PChar; { Friendly name. Supported in all readers. }
    vendorName: PChar;   { Vendor name. Supported in all readers. }
    productName: PChar;  { Product name. Supported in all readers. }
    serial: PChar;       { Serial number of the fingerprint reader. NULL if the fingeprint reader does not support this. }
  end;

{ Stores the parameters of the ISO 19794-4 image format. @see VGetReaderProperties @see VrBio_ReaderProperty }
  PISO197944Parameters = ^TISO197944Parameters;
  TISO197944Parameters = record
      compressionMode: Integer; { @see VrBio_ISO197944CompressionMode}
      impressionType: Integer;  { @see VrBio_ISO197944ImpressionType}
      fingerPosition: Integer;  { @see VrBio_ISO197944FingerPosition}
  end;

{ Represents a biometric image. @see VrBio_CaptureEventCallback \ref VSyncCapture }
  PBiometricImage = ^TBiometricImage;
  TBiometricImage = record
    width: Integer;                             { Image width. }
    height: Integer;                            { Image height }
    resolution: Integer;                        { Image resolution in dpi. For the obsolete functions, use pixels/cm.}
    channels: Integer;                          { Number of channels in the image. Fingerprint images should always be grayscale, so this value is always 1. }
    biometricModality: Integer;                 { Biometric modality. Always use VRBIO_BIOMETRIC_MODALITY_FINGERPRINT. \ref VrBio_BiometricModality. }
    scannerType: Integer;                       { Scanner type. \ref VrBio_ScannerType. }
    imageFormat: Integer;                       { Formato de imagem: Formato da imagem. \ ref VrBio_ImageFormat. }
    bufferSize: Integer;                        { Size of the buffer }
    compressionRate: Integer;                   { Compression rate. Valid for images that allow compression. \ref VrBio_CompressionRate }
    fingerQuality: Integer;                     { Quality of the fingerprint image. \ref VrBio_FingerQuality }
    ISO197944_parameters: PISO197944Parameters; { Only valid if the image if imageFormat is \ref VrBio_ImageFormat::VRBIO_IMAGEFORMAT_ISO19794_4 \ref VrBio_ISO197944Parameters }
    buffer: PByte;                              { Buffer storing the pixels of the image. The position(x,y,c) of a pixel is y*width*channels+x*channels+c. }
    reserved: Pointer;                          { Reserved for future use }
  end;

{ Fingerprint reader configuration parameters. Only works if the fingerprint scanner supports configuration. }
  TCaptureParameters = record
    brigthness: SmallInt;      { Brightness should be between 0 and 100 }
    contrast: SmallInt;        { Contrast should be between 0 and 100 }
    gain: SmallInt;            { Gain should be between 0 and 2. Any value outside these ranges is going to return \ref VrBio_ErrorCodes::VRBIO_ERROR_ARGUMENT.}
    captureType: TCaptureType; { \ref VrBio_CaptureType }
    config: PChar;             { The config parameter is used for advanced configuration. }
  end;

{ Represents a request to the license server. (OBSOLETE) @see veridisutil_makeLicenseRequest }
  TLicenseRequest = record
    host: PChar;   { License Server's host name'. Tipically "license.veridisbiometrics.com". }
    port: Integer; { License Server's port'. Tipically 80 (HTTP). }
    path: PChar;   { HTTP path. Tipically "/installLicense". }
    body: PChar;   { Request body. This must be sent to the server as POST data. }
  end;

{
  Callback function that receives events..

  readerName and image are valid only during the method execution.
  If you need to use them in your application, make a copy!

  @param[in]  eventType OR of the received event. For example, to check for a plug (eventType & VrBio_EventType::VRBIO_CAPTURE_EVENT_PLUG).
  @param[in]  image Image for the event. It is going to be not NULL for VrBio_EventType::VRBIO_CAPTURE_EVENT_IMAGE_FRAME e VrBio_EventType::VRBIO_CAPTURE_EVENT_IMAGE_CAPTURED.
  @param[in]  userData (OBSOLETE).
}
  TCaptureEventCallback = procedure (eventType: Integer; readerName: PChar; image: PBiometricImage; userData: Pointer); cdecl;

  function VStartSDK(eventCallback: TCaptureEventCallback): Integer; cdecl; external VRBIO_DLL;
  function VStopSDK(): Integer; cdecl; external VRBIO_DLL;
  function VStartReader(readerName: PChar): Integer; cdecl; external VRBIO_DLL;
  function VStopReader(readerName: PChar): Integer; cdecl; external VRBIO_DLL;
  function VGetReaderProperties(readerName: PChar; readerProperties: PReaderProperties): Integer; cdecl; external VRBIO_DLL;
  function VListDevices(devices: PPChar; N: PInteger): Integer; cdecl; external VRBIO_DLL; //???????? const char*** ?????? int *
  function VSyncCapture(readerName: PChar; timeout: Integer; out_image: PBiometricImage); cdecl; external VRBIO_DLL; //????????? VrBio_BiometricImage**
  function VLoadImageFromFile(fileName: PChar; imgResolution: Integer; imgLoaded: PBiometricImage); //??????????? VrBio_BiometricImage**


implementation

end.

If someone can direct me to correct conversion of this function. Here is an excerpt from the header that I am converting ( VrBio.h ):

/**
\file
 \ref VrBio.h
*/

#ifndef VRIMPORTDLL_H
#define VRIMPORTDLL_H


#include "VTypes.h"

#ifdef WIN32
#define DLLIMPORT extern "C" __declspec(dllimport) int __stdcall
#else
#define DLLIMPORT extern "C"
#endif

/**
  Function responsible for retrieving a list of strings, containing the readerName (uniqueName) of all connected fingerprint readers. 

  @param[out]  devices Pointer to a list of strings. The memory will be allocated by the SDK.
  @param[out]  N Size of the list.

  @return Error code.
    - \ref VrBio_ErrorCodes::VRBIO_SUCCESS
    - \ref VrBio_ErrorCodes::VRBIO_ERROR_NOT_STARTED
    - \ref VrBio_ErrorCodes::VRBIO_ERROR_ARGUMENT
    - \ref VrBio_ErrorCodes::VRBIO_ERROR_INVALID_READER_NAME
*/
DLLIMPORT  VListDevices(const char*** devices,int *N);

#endif
    
asked by anonymous 25.11.2016 / 19:39

2 answers

1

To convert DLLIMPORT VListDevices(const char*** devices,int *N)

The function declaration looks like this:

function VListDevices(devices: PPCharArray; N: PInteger): Integer; stdcall;

Calling and accessing your values looks like this:

var
  i: Integer;
  list: array of PChar;
  count: Integer;
begin
  VListDevices(@list, @count);

  for i := 0 to count -1 do
    Memo1.Lines.Add(list[i]);
end;
    
09.12.2016 / 17:54
0

Project Menu-> Import Type library Put the dll there where it generates a file * _TBL.pas It must be a COM + object

    
02.12.2016 / 16:39