Converting Delphi C ++ Header to DVP7010B DLL Graphics Card?

I need help converting a C ++ header file to Delphi.

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. 

Can the community help me transform my data correctly or guide me to a guide demonstrating how to do this?

+4
source share
4 answers

I agree with Mason that you should not use a class (at least in the beginning, when you create a wrapper and test it)
The first goal here is to access the library functions.

try like this:

 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); public procedure DisplayStatus(r:integer); end; Function AdvDVP_InitSDK():Integer ; stdcall; external 'DVP7010B.dll'; var Form1: TForm1; DVP_DLL_Handle:THandle; const SUCCEEDED = 1; FAILED = 0; SDKINITFAILED = -1; PARAMERROR = -2; NODEVICES = -3; NOSAMPLE = -4; DEVICENUMERROR = -5; INPUTERROR = -6; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var r:integer; begin if DVP_DLL_Handle <>0 then begin r := AdvDVP_InitSDK(); DisplayStatus(r); end else begin showmessage('error loading library'); end; end; procedure TForm1.DisplayStatus(r: integer); begin case r of SUCCEEDED:showmessage('SUCCEEDED'); FAILED:showmessage('FAILED'); SDKINITFAILED:showmessage('SDKINITFAILED'); PARAMERROR:showmessage('PARAMERROR'); NODEVICES:showmessage('NODEVICES'); NOSAMPLE:showmessage('NOSAMPLE'); DEVICENUMERROR:showmessage('DEVICENUMERROR'); INPUTERROR:showmessage('INPUTERROR'); end; end; initialization DVP_DLL_Handle:=LoadLibrary('DVP7010B.dll'); finalization if DVP_DLL_Handle <>0 then begin FreeLibrary(DVP_DLL_Handle); end; end. 

this is an incomplete conversion, and I put everything in one unit ...

but I downloaded the SDK and tried it: it works : I get "NODEVICES" when I click the button.

+3
source

Well, the first thing I notice is that you are trying to convert a C ++ class to a Delphi class. You cannot do this. Object models are very different. Delphi is going to make certain assumptions about how the object is laid out, and especially about how the VMT object is laid out, which is valid only for Delphi, and not for C ++.

You need either a non-object-oriented interface (plain C) or a COM object.

+1
source

Apparently AdvDVP_CreateSDKInstence does some Magic (tm) to create VMT, which is then used to send virtual function calls.

You must leave the C ++ header file and program it directly in the DLL, if you want to wrap them in a Delphi class. There are tons of tutorials you can choose, for starters, try this one . It also shows how to create enumerations in Delphi, and it has a handy little tool to create units from functions that a DLL exports.

+1
source
 unit IDVP7010BDLL_h; interface uses Windows; const DVP7010B = 'DVP7010B.dll'; MAXBOARDS = 4; 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 = 0, SIZED1, SIZEVGA, SIZEQVGA, SIZESUBQVGA); PVideoSize = ^TVideoSize; P_Pointer = ^Pointer; //TAdvDVP_CreateSDKInstence = function(var p: PIDVP7010BDLL): Integer of object; stdcall; // not needed in class TAdvDVP_InitSDK = function(): Integer of object; stdcall; TAdvDVP_CloseSDK = function(): Integer of object; stdcall; TAdvDVP_GetNoOfDevices = function(var pNoOfDevs: Integer): Integer of object; stdcall; TAdvDVP_Start = function(nDevNum: Integer; SwitchingChans: Integer; Main: HWND; hwndPreview: HWND): Integer of object; stdcall; TAdvDVP_Stop = function(nDevNum: Integer): Integer of object; stdcall; TAdvDVP_GetCapState = function(nDevNum: Integer): Integer of object; stdcall; TAdvDVP_IsVideoPresent = function(nDevNum: Integer; var VPresent: Bool): Integer of object; stdcall; TAdvDVP_GetCurFrameBuffer = function(nDevNum: Integer; VMux: Integer; var bufSize: LongInt; buf: PByte): Integer of object; stdcall; TAdvDVP_SetNewFrameCallback = function(nDevNum: Integer; callback: Integer): Integer of object; stdcall; TAdvDVP_GetVideoFormat = function(nDevNum: Integer; var vFormat: TAnalogVideoFormat): Integer of object; stdcall; TAdvDVP_SetVideoFormat = function(nDevNum: Integer; vFormat: TAnalogVideoFormat): Integer of object; stdcall; TAdvDVP_GetFrameRate = function(nDevNum: Integer; nFrameRate: Integer): Integer of object; stdcall; TAdvDVP_SetFrameRate = function(nDevNum: Integer; SwitchingChans: Integer; nFrameRate: Integer): Integer of object; stdcall; TAdvDVP_GetResolution = function(nDevNum: Integer; var Size: TVideoSize): Integer of object; stdcall; TAdvDVP_SetResolution = function(nDevNum: Integer; Size: TVideoSize): Integer of object; stdcall; TAdvDVP_GetVideoInput = function(nDevNum: Integer; var input: Integer): Integer of object; stdcall; TAdvDVP_SetVideoInput = function(nDevNum: Integer; input: Integer): Integer of object; stdcall; TAdvDVP_GetBrightness = function(nDevNum: Integer; input: Integer; var pnValue: LongInt) :Integer of object; stdcall; TAdvDVP_SetBrightness = function(nDevNum: Integer; input: Integer; nValue: LongInt) :Integer of object; stdcall; TAdvDVP_GetContrast = function(nDevNum: Integer; input: Integer; var pnValue: LongInt) :Integer of object; stdcall; TAdvDVP_SetContrast = function(nDevNum: Integer; input: Integer; nValue: LongInt) :Integer of object; stdcall; TAdvDVP_GetHue = function(nDevNum: Integer; input: Integer; var pnValue: LongInt) :Integer of object; stdcall; TAdvDVP_SetHue = function(nDevNum: Integer; input: Integer; nValue: LongInt) :Integer of object; stdcall; TAdvDVP_GetSaturation = function(nDevNum: Integer; input: Integer; var pnValue: LongInt) :Integer of object; stdcall; TAdvDVP_SetSaturation = function(nDevNum: Integer; input: Integer; nValue: LongInt) :Integer of object; stdcall; TAdvDVP_GPIOGetData = function(nDevNum: Integer; DINum: Integer; var value: Bool): Integer of object; stdcall; TAdvDVP_GPIOSetData = function(nDevNum: Integer; DONum: Integer; value: Boolean): Integer of object; stdcall; TIDVP7010BDLL = class public //AdvDVP_CreateSDKInstence: TAdvDVP_CreateSDKInstence; // not needed in class AdvDVP_InitSDK: TAdvDVP_InitSDK; AdvDVP_CloseSDK: TAdvDVP_CloseSDK; AdvDVP_GetNoOfDevices: TAdvDVP_GetNoOfDevices; AdvDVP_Start: TAdvDVP_Start; AdvDVP_Stop: TAdvDVP_Stop; AdvDVP_GetCapState: TAdvDVP_GetCapState; AdvDVP_IsVideoPresent: TAdvDVP_IsVideoPresent; AdvDVP_GetCurFrameBuffer: TAdvDVP_GetCurFrameBuffer; AdvDVP_SetNewFrameCallback: TAdvDVP_SetNewFrameCallback; AdvDVP_GetVideoFormat: TAdvDVP_GetVideoFormat; AdvDVP_SetVideoFormat: TAdvDVP_SetVideoFormat; AdvDVP_GetFrameRate: TAdvDVP_GetFrameRate; AdvDVP_SetFrameRate: TAdvDVP_SetFrameRate; AdvDVP_GetResolution: TAdvDVP_GetResolution; AdvDVP_SetResolution: TAdvDVP_SetResolution; AdvDVP_GetVideoInput: TAdvDVP_GetVideoInput; AdvDVP_SetVideoInput: TAdvDVP_SetVideoInput; AdvDVP_GetBrightness: TAdvDVP_GetBrightness; AdvDVP_SetBrightness: TAdvDVP_SetBrightness; AdvDVP_GetContrast: TAdvDVP_GetContrast; AdvDVP_SetContrast: TAdvDVP_SetContrast; AdvDVP_GetHue: TAdvDVP_GetHue; AdvDVP_SetHue: TAdvDVP_SetHue; AdvDVP_GetSaturation: TAdvDVP_GetSaturation; AdvDVP_SetSaturation: TAdvDVP_SetSaturation; AdvDVP_GPIOGetData: TAdvDVP_GPIOGetData; AdvDVP_GPIOSetData: TAdvDVP_GPIOSetData; constructor Create; // For method 2 end; PIDVP7010BDLL = ^TIDVP7010BDLL; PPIDVP7010BDLL = ^PIDVP7010BDLL; TIAdvDVP_CreateSDKInstence = function(var p: PIDVP7010BDLL): Integer; stdcall; var hDVP7010B: THandle; IAdvDVP_CreateSDKInstence: TIAdvDVP_CreateSDKInstence; implementation { TIDVP7010BDLL } constructor TIDVP7010BDLL.Create; begin if hDVP7010B <> 0 then begin //@IAdvDVP_CreateSDKInstence := GetProcAddress(hDVP7010B, 'AdvDVP_CreateSDKInstence'); // not needed @AdvDVP_InitSDK := GetProcAddress(hDVP7010B, 'AdvDVP_InitSDK'); @AdvDVP_CloseSDK := GetProcAddress(hDVP7010B, 'AdvDVP_CloseSDK'); @AdvDVP_GetNoOfDevices := GetProcAddress(hDVP7010B, 'AdvDVP_GetNoOfDevices'); @AdvDVP_Start := GetProcAddress(hDVP7010B, 'AdvDVP_Start'); @AdvDVP_Stop := GetProcAddress(hDVP7010B, 'AdvDVP_Stop'); @AdvDVP_GetCapState := GetProcAddress(hDVP7010B, 'AdvDVP_GetCapState'); @AdvDVP_IsVideoPresent := GetProcAddress(hDVP7010B, 'AdvDVP_IsVideoPresent'); @AdvDVP_GetCurFrameBuffer := GetProcAddress(hDVP7010B, 'AdvDVP_GetCurFrameBuffer'); @AdvDVP_SetNewFrameCallback := GetProcAddress(hDVP7010B, 'AdvDVP_SetNewFrameCallback'); @AdvDVP_GetVideoFormat := GetProcAddress(hDVP7010B, 'AdvDVP_GetVideoFormat'); @AdvDVP_SetVideoFormat := GetProcAddress(hDVP7010B, 'AdvDVP_SetVideoFormat'); @AdvDVP_GetFrameRate := GetProcAddress(hDVP7010B, 'AdvDVP_GetFrameRate'); @AdvDVP_SetFrameRate := GetProcAddress(hDVP7010B, 'AdvDVP_SetFrameRate'); @AdvDVP_GetResolution := GetProcAddress(hDVP7010B, 'AdvDVP_GetResolution'); @AdvDVP_SetResolution := GetProcAddress(hDVP7010B, 'AdvDVP_SetResolution'); @AdvDVP_GetVideoInput := GetProcAddress(hDVP7010B, 'AdvDVP_GetVideoInput'); @AdvDVP_SetVideoInput := GetProcAddress(hDVP7010B, 'AdvDVP_SetVideoInput'); @AdvDVP_GetBrightness := GetProcAddress(hDVP7010B, 'AdvDVP_GetBrightness'); @AdvDVP_SetBrightness := GetProcAddress(hDVP7010B, 'AdvDVP_SetBrightness'); @AdvDVP_GetContrast := GetProcAddress(hDVP7010B, 'AdvDVP_GetContrast'); @AdvDVP_SetContrast := GetProcAddress(hDVP7010B, 'AdvDVP_SetContrast'); @AdvDVP_GetHue := GetProcAddress(hDVP7010B, 'AdvDVP_GetHue'); @AdvDVP_SetHue := GetProcAddress(hDVP7010B, 'AdvDVP_SetHue'); @AdvDVP_GetSaturation := GetProcAddress(hDVP7010B, 'AdvDVP_GetSaturation'); @AdvDVP_SetSaturation := GetProcAddress(hDVP7010B, 'AdvDVP_SetSaturation'); @AdvDVP_GPIOGetData := GetProcAddress(hDVP7010B, 'AdvDVP_GPIOGetData'); @AdvDVP_GPIOSetData := GetProcAddress(hDVP7010B, 'AdvDVP_GPIOSetData'); end else MessageBox(0, 'DVP7010B.dll not found!', 'Error', MB_ICONERROR); end; initialization hDVP7010B := LoadLibrary(DVP7010B); // For method 1 if hDVP7010B <> 0 then begin @IAdvDVP_CreateSDKInstence := GetProcAddress(hDVP7010B, 'AdvDVP_CreateSDKInstence'); if @IAdvDVP_CreateSDKInstence = nil then MessageBox(0, 'AdvDVP_CreateSDKInstence not found in DVP7010B.dll', 'Error', MB_ICONERROR); end else MessageBox(0, 'DVP7010B.dll not found!', 'Error', MB_ICONERROR); finalization FreeLibrary(hDVP7010B); end. 

Test code:

 procedure TForm8.Button1Click(Sender: TObject); var pDVPSDK: PIDVP7010BDLL; res: Integer; begin // Method 1 pDVPSDK := nil; res := IAdvDVP_CreateSDKInstence(pDVPSDK); if not (res = SUCCEEDED) then begin Application.MessageBox('AdvDVP_CreateSDKInstence error!', 'Error', MB_ICONERROR); end else begin Application.MessageBox('AdvDVP_CreateSDKInstence will not work for this!!!', 'Error', MB_ICONERROR); end; end; 

Why it won’t work with Delphi: The empty Delphi 2009 class has 8 bytes (see http://blogs.teamb.com/craigstuntz/2009/03/25/38138/ for more information), and therefore the offset is AdvDVP_InitSDK and AdvDVP_CloseSDK will lead to loss and errors of other functions and I assume that this is also a mistake of the class itself.

Take a look at local variables during debugging:

  • pDVPSDK $ 1C71100
  • + AdvDVP_InitSDK ( $ 10001253 , $ 1000123A)
  • + AdvDVP_CloseSDK ($ 1000101E, $ 10001285)
  • + AdvDVP_GetNoOfDevices ($ 100011D1, $ 1000112C)
  • + ....

And from the IDA:

.text: 10001253 public AdvDVP_GetNoOfDevices

AdvDVP_InitSDK points to TAdvDVP_GetNoOfDevices !!!

Try this if you have a card yourself:

 procedure TForm8.Button2Click(Sender: TObject); var DVPSDK: TIDVP7010BDLL; res: Integer; nDevCount: Integer; i: Integer; begin // Method 2 DVPSDK := TIDVP7010BDLL.Create; try res := DVPSDK.AdvDVP_InitSDK; if res = SUCCEEDED then begin if not (DVPSDK.AdvDVP_GetNoOfDevices(nDevCount) = SUCCEEDED) then Exit; if (nDevCount > MAXBOARDS*MAXDEVS) then Exit; for i := 0 to nDevCount - 1 do begin m_DevNum.Items.Add(Format('Device_%d', [i])); // TComboBox end; end else begin case res of FAILED: Application.MessageBox('SDK function failed!', 'Error', MB_ICONERROR); SDKINITFAILED: Application.MessageBox('SDK initiation failed!', 'Error', MB_ICONERROR); PARAMERROR: Application.MessageBox('Number of the devices out of the range!', 'Error', MB_ICONERROR); NODEVICES: Application.MessageBox('No device be found!', 'Error', MB_ICONERROR); end; end; finally DVPSDK.Free; end; end; 

I don’t know if events are needed for call conversion other than stdcall, but you can try cdecl and others depending on what data you get from the functions.

Good luck.

0
source

Source: https://habr.com/ru/post/1305797/


All Articles