delphi :7写一个dll :,封装窗体,和 :ado :查询 <div>数据库 :access :</div> <div> :</div> <div>提供源码, :调试无异常,要考虑各种异常处理。</div>
主exe 程序,传递 ado 链接给 dll
能不能把需求写明确点
联系我,给你例子。QQ:80294551
附件传不上来,晕死,QQ:52926110dll中内容发一下library Padodll;usesSysUtils,Classes,Windows,Forms,dllunit in 'dllunit.pas' {dllform};exportscalldllform;{$R *.res}procedure DLLUnloadProc(Reason: Integer); register;beginif Reason = DLL_PROCESS_DETACH then beginDllfinalization;Application:=DllApplication;end;end;beginDllApplication:=Application;DLLProc := @DLLUnloadProc;end.dll中窗体,调用也简单unit dllunit;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs,DB,ADODB, StdCtrls, ExtCtrls, Grids, DBGrids;typeTDllTrItem=classAppliHandle:HWnd;MainForm:TForm;FConnection:TADOConnection;end;Tdllform = class(TForm)Panel1: TPanel;Button1: TButton;ADOQuery1: TADOQuery;DataSource1: TDataSource;DBGrid1: TDBGrid;procedure Button1Click(Sender: TObject);private{ Private declarations }publicFadoCon:TADOConnection;{ Public declarations }end;procedure calldllform(Dllitem:TDllTrItem);stdcall;far;procedure Dllfinalization; stdcall; far;varDllApplication: TApplication;implementation{$R *.dfm}procedure calldllform(Dllitem:TDllTrItem);var ptr:PLongInt;beginptr:=@(Application.MainForm);//先把dll的MainForm句柄保存起来,也无须释放,只不过是替换一下ptr^:=LongInt(Dllitem.MainForm);//用主调程序的mainForm替换DLL的MainForm。MainForm是特殊的WINDOW,它专门管理Application中的Forms资源with Tdllform.create(application) dotryFadoCon:=Dllitem.FConnection;ADOQuery1.Connection:=FadoCon;showmodal;finallyfree;end;end;procedure Dllfinalization;vari,Count:integer;obj:TComponent;beginCount:=Application.ComponentCount;for i:=Count-1 downto 0 do beginobj:=Application.Components[i];if obj.InheritsFrom(TForm) thenobj.Free;end;end;procedure Tdllform.Button1Click(Sender: TObject);beginADOQuery1.active:=False;ADOQuery1.SQL.Text:='select * from tkc';ADOQuery1.Open;end;end.