我收集的一些Delphi动态连接库资料
源代码在线查看: frmdemo.pas
unit frmDemo;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
//---这里声明需要用到的DLL中对象的方法---
TVehicle = class(TObject);
TCar = class(TVehicle)
public
procedure drive;virtual;abstract;
end;
TBicycle = class(TVehicle)
public
procedure ride;virtual;abstract;
end;
//----------------------------
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
function CarObj:TCar ;external 'DemoSvr.dll';
function BicycleObj:TBicycle ;external 'DemoSvr.dll';
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
var MyCar:TCar;
begin
MyCar:=CarObj;
if Mycar=nil then exit;
try
MyCar.drive;
finally
MyCar.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var Bicycle:TBicycle;
begin
Bicycle:=BicycleObj;
try
Bicycle.ride;
finally
Bicycle.Free;
end;
end;
end.