2013-09-01 69 views
0

你好我試圖編譯Delphi下XE4的firedac DLL開發樣品,並想出了以下錯誤德爾福XE4 E2010不兼容的類型:「紅衣主教」和「指針」

[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. 

UNIT2這是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. 
+0

我只有一個猜測。也許SharedCliHandle始終是內部指針,並且只是呈現爲Longword以更容易地處理該屬性。對於x32模式是可以的,但不適用於x64(指針是64位,但長字是32位)。所以也許他們 改變了SharedCliHandle類型的指針(至少在x64模式下),只需檢查它的類型,即使沒有源代碼,也可以在IDE中執行。 –

回答

3

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

正如你可以看到SharedCliHandle是指針,所以大概的例子是老了,你需要改變長字的指針。爲什麼LongWord早些時候和指針現在我們只能猜測,我的猜測是我作爲評論分享的。

+0

感謝您將長字改爲ACliHandle的指針,它編譯時沒有錯誤。我知道embarcadero從da-soft手中購買了firedac,但他們需要爲新的IDE(如XE4)提供新的示例項目 – CrpticMAn