gpt4 book ai didi

c++ - DVP7010B 显卡 DLL 的 C++ 头文件的 Delphi 转换?

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:49:14 26 4
gpt4 key购买 nike

我需要帮助将 C++ 头文件转换为 Delphi。

下面是原始头文件和我的Delphi翻译。

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

德尔福:

    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.

社区能否帮助我正确转换我的数据或指导我查看演示如何执行此操作的指南?

最佳答案

我同意 Mason 的观点,你不应该使用类(至少在开始构建包装器并对其进行测试时)
这里的第一个目标是调用库函数。

所以像这样尝试:

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.

这是一个不完整的转换,我把所有的都放在一个单元中......

但我下载了 SDK 并尝试了它:它有效:当我按下按钮时我得到“NODEVICES”。

关于c++ - DVP7010B 显卡 DLL 的 C++ 头文件的 Delphi 转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2563318/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com