delphi 开发扩展(二)
library plug_in;
uses
SysUtils,
Classes,
Unit3 in 'H:\test\Unit3.pas' {Form3};
exports GetForm,GetName;
{$R *.res}
begin
end.
{要加载的窗体}
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ADODB, DB, Grids, DBGrids;
type
TForm3 = class(TForm)
Button1: TButton;
ADOQuery1: TADOQuery;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
ADO: TADOConnection;
function GetName:string;StdCall;
function GetForm(AHandle:THandle;adoconn:TADOConnection;ACaption:String):BOOL;StdCall;
implementation
{$R *.dfm}
function GetName:string;
begin
result:='my dll';
end;
function GetForm(AHandle:THandle;adoconn:TADOConnection;ACaption:String):BOOL;
var
ShowForm:TForm3;
begin
Application.Handle:=AHandle;
ADO:= adoconn;
ShowForm :=TForm3.Create(Application);
try
if ACaption<>'' then
ShowForm.Caption:=ACaption;
ShowForm.ShowModal;
Result:=False;
finally
ShowForm.Free;
end;
end;
procedure TForm3.Button1Click(Sender: TObject);
begin
self.ADOQuery1.Connection:=ADO;
with self.ADOQuery1 do
begin
Connection:=ADO;
close;
SQL.Clear;
SQL.Add('select top 1 * from master');
open;
end;
end;
end.