Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database Delphi XE4 E2010不兼容类型:';红衣主教';和';指针';_Database_Delphi_Dll_Anydac_Firedac - Fatal编程技术网

Database Delphi XE4 E2010不兼容类型:';红衣主教';和';指针';

Database Delphi XE4 E2010不兼容类型:';红衣主教';和';指针';,database,delphi,dll,anydac,firedac,Database,Delphi,Dll,Anydac,Firedac,您好,我试图在delphi xe4下编译firedac dll开发示例,它出现了以下错误 [dcc32 Error] Unit1.pas(61): E2010 Incompatible types: 'Cardinal' and 'Pointer' 我已经在代码中标记了错误的位置 单元1是可执行的 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,

您好,我试图在delphi xe4下编译firedac dll开发示例,它出现了以下错误

[dcc32 Error] Unit1.pas(61): E2010 Incompatible types: 'Cardinal' and 'Pointer'
我已经在代码中标记了错误的位置

单元1是可执行的

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uADStanIntf, uADStanOption, uADStanDef, uADPhysIntf,
  uADDatSManager, uADStanParam, uADDAptIntf, StdCtrls, Grids, DBGrids,
  DB, uADPhysManager, uADPhysMSAcc, uADGUIxFormsWait, uADCompGUIx, uADCompDataSet,
  uADCompClient, uADStanError, uADGUIxIntf, uADStanPool, uADStanAsync,
  uADDAptManager, uADPhysODBCBase;

type
  TShowDataProc = procedure (ACliHandle: LongWord); stdcall;
  TShutdownProc = procedure; stdcall;

  TForm1 = class(TForm)
    ADConnection1: TADConnection;
    ADQuery1: TADQuery;
    ADGUIxWaitCursor1: TADGUIxWaitCursor;
    ADPhysMSAccessDriverLink1: TADPhysMSAccessDriverLink;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    FhDll: THandle;
    FpShowData: TShowDataProc;
    FpShutdown: TShutdownProc;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses
  uADStanUtil;

procedure TForm1.Button1Click(Sender: TObject);
begin
  FhDll := LoadLibrary(PChar('Project2.dll'));
  if FhDll = 0 then
    raise Exception.Create(ADLastSystemErrorMsg);
  @FpShowData := GetProcAddress(FhDll, PChar('ShowData'));
  if not Assigned(FpShowData) then
    raise Exception.Create(ADLastSystemErrorMsg);
  @FpShutdown := GetProcAddress(FhDll, PChar('Shutdown'));
  if not Assigned(FpShutdown) then
    raise Exception.Create(ADLastSystemErrorMsg);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  FpShowData(ADConnection1.CliHandle);   << Error is here
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  FpShutdown();
  FreeLibrary(FhDll);
  FhDll := 0;
  @FpShowData := nil;
  @FpShutdown := nil;
end;

end.
单元1;
接口
使用
窗口、消息、系统工具、变体、类、图形、控件、窗体、,
对话框,uadstantf,uADStanOption,uadstandf,uADPhysIntf,
uADDatSManager、uADStanParam、UADDatantf、StdCtrls、网格、DBGrids、,
数据库、uADPhysManager、uADPhysMSAcc、uADGUIxFormsWait、uADCompGUIx、uADCompDataSet、,
uADCompClient、uADStanError、uADGUIxIntf、uADStanPool、uADStanAsync、,
UADPhysodbcbbase uADDAptManager;
类型
TShowDataProc=过程(ACliHandle:LongWord);stdcall;
TShutdownProc=程序;stdcall;
TForm1=类(TForm)
ADConnection1:TADConnection;
ADQuery1:TADQuery;
ADGUIxWaitCursor1:TADGUIxWaitCursor;
AdphysMsAccessDriverLink 1:TADPhysMSAccessDriverLink;
数据源1:TDataSource;
DBGrid1:TDBGrid;
按钮1:t按钮;
按钮2:t按钮;
按钮3:t按钮;
程序按钮1点击(发送方:ToObject);
程序按钮3点击(发送方:ToObject);
程序按钮2点击(发送者:对象);
私有的
FhDll:THandle;
FpShowData:TShowDataProc;
FpShutdown:TShutdownProc;
结束;
变量
表1:TForm1;
实施
{$R*.dfm}
使用
uADStanUtil;
程序TForm1.按钮1单击(发送方:TObject);
开始
FhDll:=加载库(PChar('Project2.dll');
如果FhDll=0,则
引发异常。创建(ADLastSystemErrorMsg);
@FpShowData:=GetProcAddress(FhDll,PChar('ShowData'));
如果未分配(FpShowData),则
引发异常。创建(ADLastSystemErrorMsg);
@FpShutdown:=GetProcAddress(FhDll,PChar('Shutdown'));
如果未分配(FpShutdown),则
引发异常。创建(ADLastSystemErrorMsg);
结束;
程序TForm1.按钮3点击(发送方:TObject);
开始
FpShowData(ADConnection1.CliHandle)


正如您可以看到的,SharedCliHandle是指针,所以这个示例可能很旧,您需要将LongWord更改为指针。为什么之前是长词,现在是指针,我们只能猜测,我的猜测我作为评论分享

我只有一个猜测。也许SharedCliHandle在内部始终是指针,只是作为Longword显示,以便更轻松地使用此属性。对于x32模式是可以的,但对于x64(指针是64位,但长字是32位)则不行。所以,也许他们将SharedCliHandle的类型更改为指针(至少对于x64模式),只需检查它的类型,即使您没有源代码,也可以在IDE中执行。感谢您将ACliHandle的longword更改为指针,它编译时没有错误。我知道embarcadero从da soft购买了firedac,但他们需要新的示例项目,用于XE4等较新的IDE
unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uADStanIntf, uADStanOption, uADStanDef, uADPhysIntf,
  uADDatSManager, uADStanParam, uADDAptIntf, Grids, DBGrids, DB,
  uADPhysManager, uADPhysMSAcc, uADGUIxFormsWait, uADCompGUIx, uADCompDataSet,
  uADCompClient, uADStanError, uADGUIxIntf, uADStanPool, uADStanAsync,
  uADDAptManager, uADPhysODBCBase;

type
  TForm2 = class(TForm)
    ADConnection1: TADConnection;
    ADQuery1: TADQuery;
    ADGUIxWaitCursor1: TADGUIxWaitCursor;
    ADPhysMSAccessDriverLink1: TADPhysMSAccessDriverLink;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
  public
    class procedure ShowData(ACliHandle: LongWord);
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

{ TForm2 }

class procedure TForm2.ShowData(ACliHandle: LongWord);
var
  oForm: TForm2;
begin
  oForm := TForm2.Create(Application);
  oForm.ADConnection1.SharedCliHandle := ACliHandle;  <<<<<<<<<Error Here
  oForm.ADConnection1.Connected := True;
  oForm.ADQuery1.Active := True;
  oForm.Show;
end;

end.