使用delphi .net开发_第1页
使用delphi .net开发_第2页
使用delphi .net开发_第3页
使用delphi .net开发_第4页
使用delphi .net开发_第5页
已阅读5页,还剩43页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

使用 Delphi .NET开发 Using Delphi for Microsoft .NET Framework Development Delphi .NET的基本应用 Delphi .NET的开发 Delphi .NET中调用 Win32代码 Delphi .NET内核概要 主讲:周爱民 (Aimingoo) Delphi .NET的基本应用 ( 10 分钟 ) Delphi .NET的基本应用 安装 Delphi .NET的基本需求 Delphi .NET产品结构 Delphi .NET的可选件 Hello, World! Delphi .NET的调试环境 安装 Delphi .NET的基本需求 MS Internet Explorer 6.0 SP1 MS .NET Framework v1.1 MS .NET Framework SDK v1.1 MS VJ# v1.1 Redistributable MS Internet Infomation Server (IIS) MS Cassini Web Server Delphi.NET产品结构 HTML 可视环境 (Tidy) Web Services 源码版本管理 (Team) UML & MDA 数据供应器 Internet 应用开发 DBExperss接口层 多语言支持 (ITE) Delphi .NET的可选件 Hello, World! 你能想象一下, .NET版本的 ” Hello, World!” 程序会是怎样的吗? / .Net 版本的 Hello, World源代码清单 program Hello; $APPTYPE CONSOLE var Str : String = Hello, World!; begin Writeln(Str); Readln; end. Delphi .NET的调试环境 使用 .NET SDK中的 DbgCLR.EXE 使用 Octane的集成调试环境 操作演示 Delphi .NET的开发 ( 30 分钟 ) Delphi .NET的开发 Console Application Windows Forms Application VCL Forms Application Data Providers Database Application ASP .NET Web Application ASP .NET Web Services Application Web Control Library Class、 Component & Package Windows Forms Application 透过 Forms,可以轻松地访问 .NET构架的其它部分。例如使用 Windows Forms作为 Web Services的 Client,或者透过 ADO.NET界面访问数据库。 Windows Forms App. 体系结构 程序示例 VCL Forms Application 通过将 Delphi VCL映射到 .NET FCL, Borland实现了在 Delphi .NET上转化旧有系统的最简便方法。使旧有系统在 .NET上的转化成本降至最低。 Delphi for .NET 的体系结构 程序示例 Data Providers Database Application BDP为 Windows Forms App.、 ASP.NET App.,以及 Web Services提供同样的数据库接口界面。 BDP与其它 .NET数据存取方案的比较 BDP并不改变 ADO.NET的数据存取界面,而是对 Data Provider的一个实现。 BDP在 .NET数据存取体系中的地位 程序示例 ASP .NET Web Application HTML控件与 Server控件,享有与 Windows Forms控件相同的设计界面。开发 ASP.NET Web App.与 Windows Forms方法类同,甚至更容易。 ASP .NET Web App. 体系结构 Windows Forms与 ASP .NET Web App. 相似性 程序示例 ASP .NET Web Services Application 对于 Web Servers App.来说,并不关心 Client是谁,或怎样开发,而只需要提供一个访问界面。这看来象 COM组件的机制,但却与 COM无关。 ASP .NET Web Services. 数据存取结构 ASP .NET Web Services VCL .NET Application FCL .NET Application ASP .NET Application Borland Data Providers 从 Web Services的角度 来理解 Delphi .NET 应用程序的实现构架 程序示例 使用 Client访问 Internet上的 Web Servers 可以使用任何的 Client应用来访问 Web Servers。而 Delphi .NET中的 Client实现方案,比其它语言更加便捷。 Delphi .NET自动实现 Client不必要实现 程序示例 Class、 Component & Package 快速的实现一个新 Class 更好的组件设计器 (Windows Forms & ASP.NET User Control) Package管理器 程序组 (Assembly)与包 (Package) 程序示例 Delphi .NET中调用 Win32代码 ( 10 分钟 ) Delphi .NET中调用 Win32代码 托管 (Managed) 与非托管 (Unmanaged)代码 导入 DLL例程 InterOp实现对非托管代码的调用 托管 (Managed) 与非托管 (Unmanaged)代码 托管代码可以调用 DLL中的非托管函数 托管代码可以使用现有的 COM组件 (服务器 ) 非托管代码可以使用托管代码实现的服务 CLR提供的三种方案: 导入 DLL例程 program CurrentDir; $APPTYPE CONSOLE uses System.Text, / 支持 StringBuilder 类型 System.Runtime.InteropServices; / 支持 DllImport() DllImport(kernel32.dll, CharSet = CharSet.Auto, SetLastError = True, EntryPoint = GetCurrentDirectory) function GetCurrentDirectory(nBufferLength: LongWord; lpBuffer: StringBuilder): LongWord; external; var Str : StringBuilder; begin Str := StringBuilder.Create(256); Str.Length := GetCurrentDirectory(256, Str); Writeln(Str.ToString); end. 托管代码 COM组件 COM组件 托管代码实现的服务 Delphi 自动完成 RCW和 CCW的封包并生成调用代码 CLR中的 COM InterOp机制 RCW: 运行库可调用包装 CCW: COM可调用包装 程序示例 Delphi自动生成 CLR的内部机制 InterOp实现对非托管代码的调用 ( 示例: .NET版本 Microsoft Web Browser ) Delphi .NET的内核概要 ( 10 分钟 ) Delphi .NET的内核概要 GetMem()、 FreeMem()与 ReallocMem() 消失的 PChar、 Pointer和过程指针 对象类型和类类型 : Object Type & Class Type 基本类型映射: Types CTS 对象模型 映射: VCL FCL 是真正的多重继承吗? 全新的 RTL .NET Pascal语言特性 GetMem()、 FreeMem() & ReallocMem() 内存是 CLR管理的重要资源 在 Delphi .NET中, Memory Manager已经不复存在。 必要的情况下, Dynamic Array类型,和New() & Dispose()例程可以作为替代。 消失的 PChar和 Pointer 使用值类型的强制转换 (装箱操作 )来替代 如果在 API中使用 PChar,可以使用 String或者StringBuilder类型来替代 如果 PChar用于操作一个内存块,则可用 IntPtr类型或者动态数组 (TBytes)类型替代 如果在 API中使用内存块,可以使用 Marshal class从非托管堆中分配并传值 GC(garbage collector)不能管理非托管堆,因此Marshal class的实例必须显式释放 真正消失的过程指针 type TAnimateWindowProc = function(.): BOOL; stdcall; var AnimateWindowProc: TAnimateWindowProc = nil; begin AnimateWindowProc := GetProcAddress(aHandle, AnimateWindow); if AnimateWindowProc nil if CanAnimate then AnimateWindow(Handle, 100, AW_BLEND or AW_SLIDE); 什么是非安全过程 (Unsafe Procedure) 对象类型和类类型 : Object Type & Class Type 对象类型 (Object Type)是 TMyObject = Object . 在 TP5.5 Delphi 7.0中,都被支持。 KOL使用该类型实现自己的构架。 类类型 (Class Type) TMyClass = Class . Delphi 1.0 7.0的面向对象都基于类类型系统 在 Turbo Pascal 和 Delphi中: 接口 (Interface) 是编译支持的特殊的类型 IInterface = interface . 对象类型和类类型 : Object Type & Class Type 从 Turbo Pascal保留下来的原始的对象类型(Object Type)不存在了。 Delphi .NET遵循 CLR的约定,类型只能是: 继承自 TObject的引用类型 (Class Type) TObject = System.Object; TClass = class of TObject; TMyClass = TClass . 继承自 System.ValueType的值 (基元 )类型 Interface类型 在 Delphi .NET中: 基本类型映射: Types CTS 对象模型 映射: VCL FCL TObject = System.Object Exception = System.Exception TComponent = System.ComponentModel.Component 是真正的多重继承吗? CLR不支持多重继承。 多重继承特性是基于 Interface实现的。 TSomething = class(TInterfacedObject, IDescendant, IDesc) procedure P1; procedure P2; . end; 全新的 RTL Borland.Delphi.System Borland.VCL RTL = Data Type Support(Base & Interface & Object) CTS Language .NET Pascal Thread System.Threading, STA/MTA Thread Model MemMgr New() & Dispose() Exception System.Exception Other OS Resource System.xxxxx Debug Support System.Diagnostics .NET Pascal语言特性 这只是一份速食快餐,真正的内容: $(BDS)Source $(BDS)Help Danny Thorpe提供的 Delphi 8 for .NET Language Enhancements and Portability Guidelines Strings & Arrays Records Classes & Interfaces Exceptions Properties & Events Sets Text files Local Procedures Variants Components Streams New, Dispose Readln, Writeln Format Component Streaming Random Virtual Constructors 最常用的元素得以保留并重新实现 让它们从记忆中消失吧 , Addr(), Absolute directive Real48 six-byte floats File of GetMem, FreeMem, ReallocMem Use arrays or New() & Dispose() ExitPr

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论