1

Hello i was trying to compile the firedac dll development sample under delphi xe4 and it came up with the following error

[dcc32 Error] Unit1.pas(61): E2010 Incompatible types: 'Cardinal' and 'Pointer'

I have marked where the error is in the code.

Unit 1 is the executable.

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.

Unit2 which is the dll

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.
TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130
CrpticMAn
  • 13
  • 5
  • I have a guess only. Maybe SharedCliHandle was always pointer internally and just presented as Longword to work with this property easier. It is ok for x32 mode, but not for x64 (where pointer is 64 bit, but longword is 32 bit). So maybe they changed type of SharedCliHandle to pointer (at least for x64 mode), just check what type it has, you can do it in IDE even if you don't have sourcecode. – Andrei Galatyn Sep 01 '13 at 07:47

1 Answers1

3

http://docs.embarcadero.com/products/rad_studio/firedac/frames.html?frmname=topic&frmfile=uADCompClient_TADCustomConnection_SharedCliHandle.html

As you can see SharedCliHandle is pointer, so probably example is old, you need to change LongWord to pointer. Why it was LongWord earlier and pointer now we can only guess, my guess i shared as comment.

Andrei Galatyn
  • 3,322
  • 2
  • 24
  • 38
  • Thank You by changing longword to pointer for ACliHandle, it compiled without errors. I know that embarcadero bought firedac from da-soft but they need new sample projects for newer IDEs like XE4 – CrpticMAn Sep 01 '13 at 18:49