Delphi 调用Dll的两种方式

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  function RunDllFuc(a,b:Double):Double;cdecl;external'Test_DLL.DLL';//方式一
  function RunDllFuc(a,b:Double):Double;stdcall;external'Test_DLL.DLL';//方式二
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  a,b:Double;
begin
  a:=RunDllFuc(a,b);
end;

end.

该例程在Delphi XE7下通过。

你可能感兴趣的:(Delphi 调用Dll的两种方式)