I need help with converting c++ header file to delphi. I spent several days on this problem without success.
Below is the original header file and my Delphi translation.
C++ header
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifdef DVP7010BDLL_EXPORTS
#define DVP7010BDLL_API __declspec(dllexport)
#else
#define DVP7010BDLL_API __declspec(dllimport)
#endif
#define MAXBOARDS 4
#define MAXDEVS 4
#define ID_NEW_FRAME 37810
#define ID_MUX0_NEW_FRAME 37800
#define ID_MUX1_NEW_FRAME 37801
#define ID_MUX2_NEW_FRAME 37802
#define ID_MUX3_NEW_FRAME 37803
typedef enum
{
SUCCEEDED = 1,
FAILED = 0,
SDKINITFAILED = -1,
PARAMERROR = -2,
NODEVICES = -3,
NOSAMPLE = -4,
DEVICENUMERROR = -5,
INPUTERROR = -6,
// VERIFYHWERROR = -7
} Res;
typedef enum tagAnalogVideoFormat
{
Video_None = 0x00000000,
Video_NTSC_M = 0x00000001,
Video_NTSC_M_J = 0x00000002,
Video_PAL_B = 0x00000010,
Video_PAL_M = 0x00000200,
Video_PAL_N = 0x00000400,
Video_SECAM_B = 0x00001000
} AnalogVideoFormat;
typedef enum
{
SIZEFULLPAL=0,
SIZED1,
SIZEVGA,
SIZEQVGA,
SIZESUBQVGA
} VideoSize;
typedef enum
{
STOPPED = 1,
RUNNING = 2,
UNINITIALIZED = -1,
UNKNOWNSTATE = -2
} CapState;
class IDVP7010BDLL
{
public:
int AdvDVP_CreateSDKInstence(void **pp);
virtual int AdvDVP_InitSDK() PURE;
virtual int AdvDVP_CloseSDK() PURE;
virtual int AdvDVP_GetNoOfDevices(int *pNoOfDevs) PURE;
virtual int AdvDVP_Start(int nDevNum, int SwitchingChans, HWND Main, HWND hwndPreview) PURE;
virtual int AdvDVP_Stop(int nDevNum) PURE;
virtual int AdvDVP_GetCapState(int nDevNum) PURE;
virtual int AdvDVP_IsVideoPresent(int nDevNum, BOOL* VPresent) PURE;
virtual int AdvDVP_GetCurFrameBuffer(int nDevNum, int VMux, long* bufSize, BYTE* buf) PURE;
virtual int AdvDVP_SetNewFrameCallback(int nDevNum, int callback) PURE;
virtual int AdvDVP_GetVideoFormat(int nDevNum, AnalogVideoFormat* vFormat) PURE;
virtual int AdvDVP_SetVideoFormat(int nDevNum, AnalogVideoFormat vFormat) PURE;
virtual int AdvDVP_GetFrameRate(int nDevNum, int *nFrameRate) PURE;
virtual int AdvDVP_SetFrameRate(int nDevNum, int SwitchingChans, int nFrameRate) PURE;
virtual int AdvDVP_GetResolution(int nDevNum, VideoSize *Size) PURE;
virtual int AdvDVP_SetResolution(int nDevNum, VideoSize Size) PURE;
virtual int AdvDVP_GetVideoInput(int nDevNum, int* input) PURE;
virtual int AdvDVP_SetVideoInput(int nDevNum, int input) PURE;
virtual int AdvDVP_GetBrightness(int nDevNum, int input, long *pnValue) PURE;
virtual int AdvDVP_SetBrightness(int nDevNum, int input, long nValue) PURE;
virtual int AdvDVP_GetContrast(int nDevNum, int input, long *pnValue) PURE;
virtual int AdvDVP_SetContrast(int nDevNum, int input, long nValue) PURE;
virtual int AdvDVP_GetHue(int nDevNum, int input, long *pnValue) PURE;
virtual int AdvDVP_SetHue(int nDevNum, int input, long nValue) PURE;
virtual int AdvDVP_GetSaturation(int nDevNum, int input, long *pnValue) PURE;
virtual int AdvDVP_SetSaturation(int nDevNum, int input, long nValue) PURE;
virtual int AdvDVP_GPIOGetData(int nDevNum, int DINum, BOOL* value) PURE;
virtual int AdvDVP_GPIOSetData(int nDevNum, int DONum, BOOL value) PURE;
};
Delphi
unit IDVP7010BDLL_h;
interface
uses
Windows, Messages, SysUtils, Classes;
//{$if _MSC_VER > 1000}
//pragma once
//{$endif} // _MSC_VER > 1000
{$ifdef DVP7010BDLL_EXPORTS}
//const DVP7010BDLL_API = __declspec(dllexport);
{$else}
//const DVP7010BDLL_API = __declspec(dllimport);
{$endif}
const
MAXDEVS = 4;
MAXMUXS = 4;
ID_NEW_FRAME = 37810;
ID_MUX0_NEW_FRAME = 37800;
ID_MUX1_NEW_FRAME = 37801;
ID_MUX2_NEW_FRAME = 37802;
ID_MUX3_NEW_FRAME = 37803;
// TRec
SUCCEEDED = 1;
FAILED = 0;
SDKINITFAILED = -1;
PARAMERROR = -2;
NODEVICES = -3;
NOSAMPLE = -4;
DEVICENUMERROR = -5;
INPUTERROR = -6;
// TRec
// TAnalogVideoFormat
Video_None = $00000000;
Video_NTSC_M = $00000001;
Video_NTSC_M_J = $00000002;
Video_PAL_B = $00000010;
Video_PAL_M = $00000200;
Video_PAL_N = $00000400;
Video_SECAM_B = $00001000;
// TAnalogVideoFormat
// TCapState
STOPPED = 1;
RUNNING = 2;
UNINITIALIZED = -1;
UNKNOWNSTATE = -2;
// TCapState
type
TCapState = Longint;
TRes = Longint;
TtagAnalogVideoFormat = DWORD;
TAnalogVideoFormat = TtagAnalogVideoFormat;
PAnalogVideoFormat = ^TAnalogVideoFormat;
TVideoSize = ( SIZEFULLPAL, SIZED1, SIZEVGA, SIZEQVGA, SIZESUBQVGA);
PVideoSize = ^TVideoSize;
P_Pointer = ^Pointer;
TIDVP7010BDLL = class
function AdvDVP_CreateSDKInstence(pp: P_Pointer): integer; virtual; stdcall; abstract;
function AdvDVP_InitSDK():Integer; virtual; stdcall; abstract;
function AdvDVP_CloseSDK():Integer; virtual; stdcall; abstract;
function AdvDVP_GetNoOfDevices(pNoOfDevs : PInteger) :Integer; virtual; stdcall; abstract;
function AdvDVP_Start(nDevNum : Integer; SwitchingChans : Integer; Main : HWND; hwndPreview: HWND ) :Integer; virtual; stdcall; abstract;
function AdvDVP_Stop(nDevNum : Integer ):Integer; virtual; stdcall; abstract;
function AdvDVP_GetCapState(nDevNum : Integer ):Integer; virtual; stdcall; abstract;
function AdvDVP_IsVideoPresent(nDevNum : Integer; VPresent : PBool) :Integer; virtual; stdcall; abstract;
function AdvDVP_GetCurFrameBuffer(nDevNum : Integer; VMux : Integer; bufSize : PLongInt; buf : PByte) :Integer; virtual; stdcall; abstract;
function AdvDVP_SetNewFrameCallback(nDevNum : Integer; callback : Integer ) :Integer; virtual; stdcall; abstract;
function AdvDVP_GetVideoFormat(nDevNum : Integer; vFormat : PAnalogVideoFormat) :Integer; virtual; stdcall; abstract;
function AdvDVP_SetVideoFormat(nDevNum : Integer; vFormat : TAnalogVideoFormat ) :Integer; virtual; stdcall; abstract;
function AdvDVP_GetFrameRate(nDevNum : Integer; nFrameRate : Integer) :Integer; virtual; stdcall; abstract;
function AdvDVP_SetFrameRate(nDevNum : Integer; SwitchingChans : Integer; nFrameRate : Integer) :Integer; virtual; stdcall; abstract;
function AdvDVP_GetResolution(nDevNum : Integer; Size : PVideoSize) :Integer; virtual; stdcall; abstract;
function AdvDVP_SetResolution(nDevNum : Integer; Size : TVideoSize ) :Integer; virtual; stdcall; abstract;
function AdvDVP_GetVideoInput(nDevNum : Integer; input : PInteger) :Integer; virtual; stdcall; abstract;
function AdvDVP_SetVideoInput(nDevNum : Integer; input : Integer) :Integer; virtual; stdcall; abstract;
function AdvDVP_GetBrightness(nDevNum : Integer; input: Integer; pnValue : PLongInt) :Integer; virtual; stdcall; abstract;
function AdvDVP_SetBrightness(nDevNum : Integer; input: Integer; nValue : LongInt) :Integer; virtual; stdcall; abstract;
function AdvDVP_GetContrast(nDevNum : Integer; input: Integer; pnValue : PLongInt) :Integer; virtual; stdcall; abstract;
function AdvDVP_SetContrast(nDevNum : Integer; input: Integer; nValue : LongInt) :Integer; virtual; stdcall; abstract;
function AdvDVP_GetHue(nDevNum : Integer; input: Integer; pnValue : PLongInt) :Integer; virtual; stdcall; abstract;
function AdvDVP_SetHue(nDevNum : Integer; input: Integer; nValue : LongInt) :Integer; virtual; stdcall; abstract;
function AdvDVP_GetSaturation(nDevNum : Integer; input: Integer; pnValue : PLongInt) :Integer; virtual; stdcall; abstract;
function AdvDVP_SetSaturation(nDevNum : Integer; input: Integer; nValue : LongInt) :Integer; virtual; stdcall; abstract;
function AdvDVP_GPIOGetData(nDevNum : Integer; DINum:Integer; value : PBool) :Integer; virtual; stdcall; abstract;
function AdvDVP_GPIOSetData(nDevNum : Integer; DONum:Integer; value : Boolean) :Integer; virtual; stdcall; abstract;
end;
function IDVP7010BDLL : TIDVP7010BDLL ; stdcall;
implementation
function IDVP7010BDLL; external 'DVP7010B.dll';
end.