Delphi制作Dll全集(0分)

我遇到的问题与ynjinti一样,想在主控程序控制Dll中的MDIChildForm,<br>非常想知道解决问题的方法。<br>&nbsp; &nbsp;lbmjy@163.net
 
贴出来嘛,好东东,要大家分享才好。
 
洗耳恭听!
 
嘿嘿,其实从DLL中创建Form(无论室MDI还是其他FORM)有另外一种方法,至今不太见到,其实<br>DLL和EXE在同一进程空间,那和BPL有什么不一样呢?为什么BPL可以直接使用其类,而DLL就不<br>可以?当然可以!答案在D2 Unleashed里(后续的Unleasned里反而不见了).
 
dll学习的书籍中,有几本讲的较好,<br>其一为:delphi5开发人员指南《机械工业出版社》2000年//非常好,建议购买<br>其二为:《精通delphi》姚庭宝 电子工业出版社 1997年<br>其三为: 《delphi2 程序设计大全》《机械工业出版社》//好,想买也买不到<br><br>COM:<br>1、delphi com 深入编程 机械工业出版社<br>2、徐新华的书,书名忘了//深入不浅出<br>3、李维delphi5.x高级程序设计篇//好,有高手风范<br><br>数据库及电子商务<br>李维的delphi5.x丛书<br><br>控件制作、使用<br>1、delphi第三方控件使用大全 中国水利水电出版社//建议不要买,看看就可以了<br>2、delphi部件开发编程深入剖析 机械工业出版社 &nbsp;//其中有一个数值计算控件蛮好的<br><br>opengl<br>open gl 三维图形设计与制作 人民邮电出版社 //c++的例子<br>可视化opengl程序设计 清华大学出版社//较好,有示例<br>delphi 多媒体特效制作百例//中国电力出版社 ,看看就行了,不要买,将随书的光盘栲下来就可以<br><br>操纵office <br>网上有很多例子,查找一下就可以了<br><br><br>以上是我这4年的学习心得,大家可以参考一下!!
 
太好了.我已经看到阿朱的好几个好文了.多谢了:)!!!!!!!!!!!!!!!
 
没什么好说的了,谢谢!
 
阿朱:谢谢你了:tkggai@sian.com
 
主程序:<br>function dcs_logon(input:tstringlist):Tstringlist;far; external 'logondll.DLL';<br><br>var<br>&nbsp; namelist:Tstringlist;<br>begin<br>&nbsp; namelist:=Tstringlist.Create;<br>&nbsp; namelist.Append('dcs');<br>&nbsp; try<br>&nbsp; namelist:=dcs_logon(namelist);<br>&nbsp; except<br>&nbsp; end;<br>&nbsp; if namelist.Strings[0]='0' then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; label1.Caption:='用户名:'+namelist.Strings[1];<br>&nbsp; &nbsp; label2.Caption:='密码:'+namelist.Strings[2];<br>&nbsp; &nbsp; end<br>&nbsp; else<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; label1.Caption:='用户取消登录';<br>&nbsp; &nbsp; label2.Caption:='';<br>&nbsp; &nbsp; end;<br>end;<br><br>dll程序:<br>uses<br>&nbsp; SysUtils,<br>&nbsp; Classes,<br>&nbsp; loginunit in 'loginunit.pas' {loginform};<br><br>{$R *.RES}<br>exports<br>&nbsp; dcs_logon index 1;<br>begin<br>end.<br><br>function dcs_logon(input:tstringlist):Tstringlist;<br>var<br>&nbsp; loginform: Tloginform;<br>begin<br>&nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; loginform:=Tloginform.Create(application);<br>&nbsp; &nbsp; &nbsp; &nbsp; loginform.ComboBox1.Items.Clear;<br>&nbsp; &nbsp; &nbsp; &nbsp; loginform.ComboBox1.Items.AddStrings(input);<br>&nbsp; &nbsp; &nbsp; &nbsp; loginform.ShowModal;<br>&nbsp; &nbsp; &nbsp; &nbsp; res.Strings[1]:=loginform.ComboBox1.Text;<br>&nbsp; &nbsp; &nbsp; &nbsp; res.Strings[2]:=loginform.Edit2.Text;<br>&nbsp; &nbsp; &nbsp; &nbsp; result:=res;<br>&nbsp; &nbsp; finally<br>&nbsp; &nbsp; &nbsp; &nbsp; loginform.Free;<br>&nbsp; &nbsp; end;<br>end;<br>
 
关于制作DLL,&lt;delphi 5开发人员指南第九章有详细介绍,以下是目录:<br>第9章 &nbsp; 动态链接库 234<br>9.1 &nbsp; 究竟什么是DLL 234<br>9.2 &nbsp; 静态链接与动态链接 235<br>9.3 &nbsp; 为什么要使用DLL 236<br>9.3.1 &nbsp; 共享代码、资源和数据 236<br>9.3.2 &nbsp; 隐藏实现的细节 237<br>9.3.3 &nbsp; 自定义控件 237<br>9.4 &nbsp; 创建和使用DLL 237<br>9.4.1 &nbsp; 数美分:一个简单的DLL 237<br>9.4.2 &nbsp; 显示DLL中的模式窗体 239<br>9.5 &nbsp; 显示DLL中的无模式窗体 241<br>9.6 &nbsp; 在Delphi应用程序中使用DLL 242<br>9.7 &nbsp; DLL的入口函数和出口函数 246<br>9.7.1 &nbsp; 进程/线程初始化和终止例程 246<br>9.7.2 &nbsp; DLL入口/出口示例 246<br>9.8 &nbsp; DLL中的异常 250<br>9.8.1 &nbsp; 在16位Delphi中捕捉异常 250<br>9.8.2 &nbsp; 异常和Safecall指示符 250<br>9.9 &nbsp; 回调函数 250<br>9.9.1 &nbsp; 使用回调函数 253<br>9.9.2 &nbsp; 拥有者绘制的列表框 253<br>9.10 &nbsp; 从DLL中调用回调函数 253<br>9.11 &nbsp; 在不同的进程间共享DLL数据 256<br>9.11.1 &nbsp; 一个可以被共享数据的DLL 256<br>9.11.2 &nbsp; 访问DLL中的共享数据 259<br>9.12 &nbsp; 引出DLL中的对象 261<br>9.13 &nbsp; 总结 265<br>
 
接受答案了.
 
给分给分,当然要给分了,谢谢各位了!
 
动态调用。<br><br>dll 调用部分:<br><br>{****************************************************************}<br>{ }<br>{ Project: DllDebug &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;            }<br>{ Copyright(c) 2003, 2005                 }<br>{ Unit for UCommonUnit &nbsp;    &nbsp; &nbsp; &nbsp;              &nbsp;}<br>{ Create &nbsp;: 2003-01-05 by 林红卫             }<br>{ Modify &nbsp;: 2003-01-16 by 林红卫             }<br>{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>{****************************************************************}<br><br>unit UCommonUnit;<br><br>interface<br><br>uses<br>&nbsp; Windows,<br>&nbsp; SysUtils,<br>&nbsp; Forms;<br><br>type<br>&nbsp; TRunDLL = procedure(DLLName, FormName, FormCaption: PChar;<br>&nbsp; &nbsp; aApp: TApplication; Scr: TScreen) stdcall;<br><br>procedure RunDLLForm(DLLName, FormName, FormCaption: string;<br>&nbsp; aApp: TApplication; Scr: TScreen) stdcall;<br><br>implementation<br><br>procedure RunDLLForm(DLLName, FormName, FormCaption: string;<br>&nbsp; aApp: TApplication; Scr: TScreen) stdcall;<br>var<br>&nbsp; RunDLL: TRunDLL;<br>&nbsp; GetDllHWND: HWND;<br>begin<br>&nbsp; GetDllHWND := LoadLibrary(PChar(DllName));<br>&nbsp; try<br>&nbsp; &nbsp; if GetDllHWND &lt; 32 then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; MessageBox(0, '没有找到附带DLL文件,请确认程序是否完整!',<br>&nbsp; &nbsp; &nbsp; &nbsp; '加载DLL失败', MB_OK);<br>&nbsp; &nbsp; &nbsp; Exit;<br>&nbsp; &nbsp; end;<br><br>&nbsp; &nbsp; @RunDLL := GetProcAddress(GetDllHWND, 'RunDLL');<br>&nbsp; &nbsp; if @RunDLL &lt;&gt; nil then<br>&nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; RunDLL(PChar(UpperCase(Trim(DLLName))), PChar(UpperCase(Trim(FormName))),<br>&nbsp; &nbsp; &nbsp; &nbsp; PChar(FormCaption), aApp,Scr);<br>&nbsp; &nbsp; except<br>&nbsp; &nbsp; &nbsp; raise Exception.Create('T' + FormName + '不存在!');<br>&nbsp; &nbsp; end;<br>&nbsp; finally<br>&nbsp; &nbsp; FreeLibrary(GetDllHWND);<br>&nbsp; end;<br>end;<br><br>end.<br><br>dll :<br><br>{****************************************************************}<br>{ }<br>{ Project: UDllTest   &nbsp; &nbsp; &nbsp; &nbsp;            }<br>{ Copyright(c) 2003, 2005                 }<br>{ Unit for UDllTest &nbsp; &nbsp;     &nbsp; &nbsp; &nbsp;              &nbsp;}<br>{ Create &nbsp;: 2003-01-05 by 林红卫             }<br>{ Modify &nbsp;: 2003-01-16 by 林红卫             }<br>{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br>{****************************************************************}<br><br>library UDllTest;<br><br>uses<br>&nbsp; SysUtils,<br>&nbsp; Forms,<br>&nbsp; Messages,<br>&nbsp; Variants,<br>&nbsp; Windows,<br>&nbsp; Classes,<br>&nbsp; UFrmTestForm1 in 'UFrmTestForm1.pas' {Form1},<br>&nbsp; UFrmTestForm2 in 'UFrmTestForm2.pas' {Form2};<br><br>var<br>&nbsp; DLLApp: TApplication;<br>&nbsp; DLLScreen: TScreen;<br><br>procedure RunDLL(DLLName, FormName, FormCaption: PChar;<br>&nbsp; aApp: TApplication; Scr: TScreen) stdcall;<br>var<br>&nbsp; TheClass: TPersistentClass;<br>&nbsp; aForm: TForm;<br>begin<br>&nbsp; Application := aApp;<br>&nbsp; Screen := Scr;<br>&nbsp; RegisterClasses([TForm1, TForm2]);<br><br>&nbsp; TheClass := GetClass('T' + FormName);<br>&nbsp; if (TheClass = nil) then<br>&nbsp; &nbsp; GetLastError;<br><br>&nbsp; if TheClass.InheritsFrom(TForm)<br>&nbsp; &nbsp; and (TheClass &lt;&gt; TForm) then<br>&nbsp; begin<br>&nbsp; &nbsp; aForm := TForm(TheClass.Create).Create(nil);<br>&nbsp; &nbsp; aForm.Caption := FormCaption;<br>&nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; aForm.ShowModal;<br>&nbsp; &nbsp; finally<br>&nbsp; &nbsp; &nbsp; FreeAndNil(aForm);<br>&nbsp; &nbsp; end;<br>&nbsp; end;<br>end;<br><br>procedure DLLUnloadProc(dwReason: DWORD);<br>begin<br>&nbsp; if dwReason = DLL_PROCESS_DETACH then<br>&nbsp; begin<br>&nbsp; &nbsp; Application := DLLApp; //恢复<br>&nbsp; &nbsp; Screen := DLLScreen;<br>&nbsp; end;<br>end;<br><br>exports<br>&nbsp; RunDLL;<br><br>begin<br>&nbsp; DLLApp := Application; //保存 DLL 中初始的 Application 对象<br>&nbsp; DLLScreen := Screen;<br>&nbsp; DLLProc := @DLLUnloadProc; //保证 DLL 卸载时恢复原来的 Application<br>&nbsp; DLLUnloadProc(DLL_PROCESS_DETACH);<br>end.<br>
 
to 阿朱想和你讨论dllform的有些问题<br>我的邮件是looyo@163.com
 
来自:EdwinYeah, 时间:2001-11-10 22:01:00, ID:722012 <br>!!!!!!!!!!!!!!!关于制作DLL,&lt;delphi 5开发人员指南第九章有详细介绍,以下是目录:<br>这位仁兄。 你下面所写的目录我在另一本书上也看过。 &lt;&lt;Delphi4 开发大全&gt;&gt;(上下)<br>美国 Steve Teixeira Xavier Pacheco 著<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;徐新华 &nbsp;译<br>&nbsp; 人民邮电出版社<br>&nbsp; 这套在世面上可是很少见的了。也许没有了。 还好,我这有。<br>&nbsp; 不会是D5 的作者 摘要 人家的吧。 &nbsp;目录完一样,一个字都不错,当然,书页不同。[8D]<br><br>第9章 &nbsp; 动态链接库 234<br>9.1 &nbsp; 究竟什么是DLL 234<br>9.2 &nbsp; 静态链接与动态链接 235<br>9.3 &nbsp; 为什么要使用DLL 236<br>9.3.1 &nbsp; 共享代码、资源和数据 236<br>9.3.2 &nbsp; 隐藏实现的细节 237<br>9.3.3 &nbsp; 自定义控件 237<br>9.4 &nbsp; 创建和使用DLL 237<br>9.4.1 &nbsp; 数美分:一个简单的DLL 237<br>9.4.2 &nbsp; 显示DLL中的模式窗体 239<br>9.5 &nbsp; 显示DLL中的无模式窗体 241<br>9.6 &nbsp; 在Delphi应用程序中使用DLL 242<br>9.7 &nbsp; DLL的入口函数和出口函数 246<br>9.7.1 &nbsp; 进程/线程初始化和终止例程 246<br>9.7.2 &nbsp; DLL入口/出口示例 246<br>9.8 &nbsp; DLL中的异常 250<br>9.8.1 &nbsp; 在16位Delphi中捕捉异常 250<br>9.8.2 &nbsp; 异常和Safecall指示符 250<br>9.9 &nbsp; 回调函数 250<br>9.9.1 &nbsp; 使用回调函数 253<br>9.9.2 &nbsp; 拥有者绘制的列表框 253<br>9.10 &nbsp; 从DLL中调用回调函数 253<br>9.11 &nbsp; 在不同的进程间共享DLL数据 256<br>9.11.1 &nbsp; 一个可以被共享数据的DLL 256<br>9.11.2 &nbsp; 访问DLL中的共享数据 259<br>9.12 &nbsp; 引出DLL中的对象 261<br>9.13 &nbsp; 总结 265<br><br><br>&nbsp;<br>
 
顶部