草庐IT

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

coder 2024-02-20 原文

我需要帮助将 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/

有关c++ - DVP7010B 显卡 DLL 的 C++ 头文件的 Delphi 转换?的更多相关文章

  1. ruby - 使用 RubyZip 生成 ZIP 文件时设置压缩级别 - 2

    我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看ruby​​zip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d

  2. ruby - 其他文件中的 Rake 任务 - 2

    我试图在一个项目中使用rake,如果我把所有东西都放到Rakefile中,它会很大并且很难读取/找到东西,所以我试着将每个命名空间放在lib/rake中它自己的文件中,我添加了这个到我的rake文件的顶部:Dir['#{File.dirname(__FILE__)}/lib/rake/*.rake'].map{|f|requiref}它加载文件没问题,但没有任务。我现在只有一个.rake文件作为测试,名为“servers.rake”,它看起来像这样:namespace:serverdotask:testdoputs"test"endend所以当我运行rakeserver:testid时

  3. ruby-on-rails - 在 Rails 中将文件大小字符串转换为等效千字节 - 2

    我的目标是转换表单输入,例如“100兆字节”或“1GB”,并将其转换为我可以存储在数据库中的文件大小(以千字节为单位)。目前,我有这个:defquota_convert@regex=/([0-9]+)(.*)s/@sizes=%w{kilobytemegabytegigabyte}m=self.quota.match(@regex)if@sizes.include?m[2]eval("self.quota=#{m[1]}.#{m[2]}")endend这有效,但前提是输入是倍数(“gigabytes”,而不是“gigabyte”)并且由于使用了eval看起来疯狂不安全。所以,功能正常,

  4. ruby-on-rails - Rails 3 中的多个路由文件 - 2

    Rails2.3可以选择随时使用RouteSet#add_configuration_file添加更多路由。是否可以在Rails3项目中做同样的事情? 最佳答案 在config/application.rb中:config.paths.config.routes在Rails3.2(也可能是Rails3.1)中,使用:config.paths["config/routes"] 关于ruby-on-rails-Rails3中的多个路由文件,我们在StackOverflow上找到一个类似的问题

  5. ruby - 将差异补丁应用于字符串/文件 - 2

    对于具有离线功能的智能手机应用程序,我正在为Xml文件创建单向文本同步。我希望我的服务器将增量/差异(例如GNU差异补丁)发送到目标设备。这是计划:Time=0Server:hasversion_1ofXmlfile(~800kiB)Client:hasversion_1ofXmlfile(~800kiB)Time=1Server:hasversion_1andversion_2ofXmlfile(each~800kiB)computesdeltaoftheseversions(=patch)(~10kiB)sendspatchtoClient(~10kiBtransferred)Cl

  6. ruby - 使用 ruby​​ 将 HTML 转换为纯文本并维护结构/格式 - 2

    我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h

  7. ruby - 如何将脚本文件的末尾读取为数据文件(Perl 或任何其他语言) - 2

    我正在寻找执行以下操作的正确语法(在Perl、Shell或Ruby中):#variabletoaccessthedatalinesappendedasafileEND_OF_SCRIPT_MARKERrawdatastartshereanditcontinues. 最佳答案 Perl用__DATA__做这个:#!/usr/bin/perlusestrict;usewarnings;while(){print;}__DATA__Texttoprintgoeshere 关于ruby-如何将脚

  8. ruby - 使用 Vim Rails,您可以创建一个新的迁移文件并一次性打开它吗? - 2

    使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta

  9. ruby - 将数组的内容转换为 int - 2

    我需要读入一个包含数字列表的文件。此代码读取文件并将其放入二维数组中。现在我需要获取数组中所有数字的平均值,但我需要将数组的内容更改为int。有什么想法可以将to_i方法放在哪里吗?ClassTerraindefinitializefile_name@input=IO.readlines(file_name)#readinfile@size=@input[0].to_i@land=[@size]x=1whilex 最佳答案 只需将数组映射为整数:@land边注如果你想得到一条线的平均值,你可以这样做:values=@input[x]

  10. ruby - 将散列转换为嵌套散列 - 2

    这道题是thisquestion的逆题.给定一个散列,每个键都有一个数组,例如{[:a,:b,:c]=>1,[:a,:b,:d]=>2,[:a,:e]=>3,[:f]=>4,}将其转换为嵌套哈希的最佳方法是什么{:a=>{:b=>{:c=>1,:d=>2},:e=>3,},:f=>4,} 最佳答案 这是一个迭代的解决方案,递归的解决方案留给读者作为练习:defconvert(h={})ret={}h.eachdo|k,v|node=retk[0..-2].each{|x|node[x]||={};node=node[x]}node[

随机推荐