[英]Delphi XE4 E2010 Incompatible types: 'Cardinal' and 'Pointer'
您好,我试图在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.
dll是Unit2
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.
如您所见,SharedCliHandle是指针,因此示例可能很旧,您需要将LongWord更改为指针。 为什么以前是LongWord,现在是指针,我们只能猜测,我的猜测是我的评论。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.