delphi 捕获源_了解Delphi项目和单元源文件

delphi 捕获源

In short, a Delphi project is just a collection of files that make up an application created by Delphi. DPR is the file extension used for the Delphi Project file format to store all the files related to the project. This includes other Delphi file types like Form files (DFMs) and Unit Source files (.PASs).

简而言之,Delphi项目只是构成由Delphi创建的应用程序的文件集合 。 DPR是用于Delphi Project文件格式的文件扩展名,用于存储与项目相关的所有文件。 这包括其他Delphi文件类型,例如表单文件(DFM)和单位源文件(.PAS)。

Since it's quite common for Delphi applications to share code or previously customized forms, Delphi organizes applications into these project files. The project is made up of the visual interface along with the code that activates the interface.

由于Delphi应用程序共享代码或以前自定义的表单非常普遍,因此Delphi将应用程序组织到这些项目文件中。 该项目由可视界面以及激活该界面的代码组成。

Each project can have multiple forms that let you build applications that have multiple windows. The code that's needed for a form is stored in the DFM file, which can also contain general source code information that can be shared by all the application's forms.

每个项目可以具有多种形式,使您可以构建具有多个窗口的应用程序。 表单所需的代码存储在DFM文件中,该文件还可以包含可以由所有应用程序表单共享的常规源代码信息。

A Delphi project cannot be compiled unless a Windows Resource file (RES) is used, which holds the program's icon and version information. It might also contain other resources too, like images, tables, cursors, etc. RES files are generated automatically by Delphi.

除非使用Windows资源文件(RES)(该文件包含程序的图标和版本信息),否则无法编译Delphi项目。 它还可能包含其他资源,例如图像,表,光标等。RES文件由Delphi自动生成。

Note: Files that end in the DPR file extension are also Digital InterPlot files used by the Bentley Digital InterPlot program, but they have nothing to do with Delphi projects.

注意:以DPR文件扩展名结尾的文件也是Bentley Digital InterPlot程序使用的Digital InterPlot文件,但与Delphi项目无关。

DPR文件 ( DPR Files )

The DPR file contains directories for building an application. This is normally a set of simple routines which open the main form and any other forms that are set to be opened automatically. It then starts the program by calling the Initialize, CreateForm, and Run methods of the global Application object.

DPR文件包含用于构建应用程序的目录。 通常,这是一组简单的例程,这些例程会打开主窗体以及任何其他设置为自动打开的窗体。 然后,它通过调用全局Application对象的InitializeCreateFormRun方法来启动程序。

The global variable Application, of type TApplication, is in every Delphi Windows application. Application encapsulates your program as well as provides many functions that occur in the background of the software.

TApplication类型的全局变量Application在每个Delphi Windows应用程序中。 应用程序封装了您的程序,并提供了在软件后台发生的许多功能。

For example, Application handles how you would call a help file from the menu of your program.

例如,应用程序处理如何从程序菜单中调用帮助文件。

DPROJ is another file format for Delphi Project files, but instead, stores project settings in the XML format.

DPROJ是Delphi Project文件的另一种文件格式,但是以XML格式存储项目设置。

PAS文件 ( PAS Files )

The PAS file format is reserved for the Delphi Unit Source files. You can view the current project's source code through the Project > View Source menu.

PAS文件格式是为Delphi单位源文件保留的。 您可以通过“ 项目”>“查看源代码”菜单查看当前项目的源代码。

Although you can read and edit the project file like you would any source code, in most cases, you will let Delphi maintain the DPR file. The main reason to view the project file is to see the units and forms that make up the project, as well as to see which form is specified as the application's "main" form.

尽管您可以像读取任何源代码一样读取和编辑项目文件,但是在大多数情况下,您可以让Delphi维护DPR文件。 查看项目文件的主要原因是查看组成项目的单元和表格,以及查看将哪个表格指定为应用程序的“主”表格。

Another reason to work with the project file is when you're creating a DLL file rather than a standalone application. Or, if you need some startup code, such as a splash screen before the main form is created by Delphi.

使用项目文件的另一个原因是在创建DLL文件而不是独立应用程序时。 或者,如果您需要一些启动代码,例如在Delphi创建主表单之前启动屏幕

This is the default project file source code for a new application that has one form called "Form1:"

这是新应用程序的默认项目文件源代码,该应用程序具有一种称为“ Form1:”的形式。

 program Project1;uses
 Forms,
 Unit1 in 'Unit1.pas' {Form1};{$R *.RES}begin
 Application.Initialize;
 Application.CreateForm(TForm1, Form1) ;
 Application.Run;
 end. 

Below is an explanation of each of the PAS file's components:

以下是每个PAS文件组件的说明:

"program"

程序

This keyword identifies this unit as a program's main source unit. You can see that the unit name, "Project1," follows the program keyword. Delphi gives the project a default name until you save it as something different.

此关键字将该单元标识为程序的主要源单元。 您会看到在程序关键字后面跟随着单元名称“ Project1”。 在将项目另存为其他名称之前,Delphi会为项目提供默认名称。

When you run a project file from the IDE, Delphi uses the name of the Project file for the name of the EXE file that it creates. It reads the "uses" clause of the project file to determine which units are part of a project.

当您从IDE运行项目文件时,Delphi会将项目文件的名称用作它创建的EXE文件的名称。 它读取项目文件的“ uses”子句,以确定哪些单元是项目的一部分。

"{$R *.RES}"

{$ R * .RES}

The DPR file is linked to the PAS file with the compile directive {$R *.RES}. In this case, the asterisk represents the root of the PAS file name rather than "any file." This compiler directive tells Delphi to include this project's resource file, like its icon image.

DPR文件通过编译指令{$ R * .RES}链接到PAS文件。 在这种情况下,星号表示PAS文件名的根,而不是“任何文件”。 该编译器指令告诉Delphi包括该项目的资源文件,例如其图标图像。

"begin and end"

开始结束

The "begin" and "end" block is the main source code block for the project.

“ begin”和“ end”块是项目的主要源代码块。

"Initialize"

初始化

Although "Initialize" is the first method called in the main source code, it isn't the first code that's executed in an application. The application first executes the "initialization" section of all the units used by the application.

尽管“ Initialize”是主要源代码中调用的第一个方法,但它不是在应用程序中执行的第一个代码。 应用程序首先执行“初始化” 应用程序使用的所有单位的“部分”。

"Application.CreateForm"

Application.CreateForm

The "Application.CreateForm" statement loads the form specified in its argument. Delphi adds an Application.CreateForm statement to the project file for each form that's included.

“ Application.CreateForm”语句加载在其参数中指定的表单。 Delphi将包含的每个表单的Application.CreateForm语句添加到项目文件中。

This code's job is to first allocate memory for the form. The statements are listed in the order that the forms are added to the project. This is the order that the forms will be created in memory at runtime.

该代码的工作是首先为表单分配内存。 这些语句按将表单添加到项目的顺序列出。 这是在运行时在内存中创建表单的顺序。

If you want to change this order, do not edit the project source code. Instead, use the Project > Options menu.

如果要更改此顺序,请不要编辑项目源代码。 而是使用“ 项目”>“选项”菜单。

"Application.Run"

Application.Run

The "Application.Run" statement starts the application. This instruction tells the pre-declared object called Application, to begin processing the events that occur during the run of a program.

“ Application.Run”语句启动应用程序。 该指令告诉预先声明的对象Application,开始处理程序运行期间发生的事件。

隐藏主窗体/任务栏按钮的示例 ( Example of Hiding the Main Form/Taskbar Button )

The Application object's "ShowMainForm" property determines whether or not a form will show at startup. The only condition for setting this property is that it has to be called before the "Application.Run" line.

Application对象的“ ShowMainForm”属性确定在启动时是否显示表单。 设置此属性的唯一条件是必须在“ Application.Run”行之前调用它。

 //Presume: Form1 is the MAIN FORM
 Application.CreateForm(TForm1, Form1) ;
 Application.ShowMainForm := False;
 Application.Run;

翻译自: https://www.thoughtco.com/understanding-delphi-project-files-dpr-1057652

delphi 捕获源

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Delphi实例开发教程》代码包说明 __________________________________________________________________ (一)代码程序包内容: 代码程序包的目录结构如下: \(根目录) | |————Readme.txt(说明文件必须放在这个地方) | |————\本书大案例(目录) | | |————|————DataBase(目录,存放大案例的数据库文件为“date”和数据库连接文件TEST.UDL) | | |————|————Materials(目录,存放大案例的登录logo) | | |————|————EXE(目录,存放可执行文件,为channelplay.exe) | | |————|————Setup(目录,存放安装文件) | | |————|————Source(目录,存放代码,这个目录可以进一步细分) | | |————|————|————code(保存程序) | | |————|————|————dcu(保存中间编译文件) | | |————|————|————exe(保存可执行文件) 其中安装程序文件夹里面是本案例系统的安装程序,与程序代码无关。用户既可以以它来安装信息搜索系统程序,也可以直接从setup文件夹中直接运行程序。(当然,两者前提是数据库配置好,具体的配置方法参考案例书第4章的案例分析与完善) 另外在source文件夹中还有三个文件夹,code,dcu与exe是在编写程序代码是为了方便管理而设置的(这里的exe文件夹中文件和大案例下的EXE文件夹一样)。在一般情况下,如果不对编写的delphi项目工程进行设置而直接保存到一个文件中,那么在运行程序代码是就会在此文件夹中产生中间编译文件和最后的运行程序。如此则这同一个文件夹中就不仅有项目文件、单元文件也会有在编译过程中产生的编译文件和最后程序等。这样就不方便程序的管理和查看。所以在编写delphi项目工程之前最后设置三个文件夹分别用于保存程序代码、中间的编译文件和应用程序,以方便管理。(具体设置是先打开delphi7,选择[Project]->[options],打开一个对话框,directories/Conditionals页,在Output directory里填写保存应用程序的文件夹路径,在Unit Output directory填写保存中间编译文件的文件夹路径。这两个路径最后写与程序代码文件夹相关的相对路径。如本书的项目工程,程序代码保存在code文件夹中,那么Output directory里填写“..\exe”,而Unit Output directory里填写“..\dcu”。) (二)下面介绍大案例code文件夹里各个文件的内容和关系:(code文件夹里的几个文件夹都与本程序无关,可以删除) 1)ChannelPlayer.dpr-------本案例的工程文件 它说明项目中各个单元文件的运行创建,并启动生成应用程序 2)MainFrm.dfm-----------------主窗体的窗体文件 它保存软件主界面窗体所作的属性 MainFrm.pas------------------主窗体的单元文件 它保存与软件主界面窗体相关的程序代码 以下各组文件的内容可以参考本书的第二章的实例分析与完善 3)MaintainFrm.dfm---------------对已保存的定制进行修改维护的窗体文件 MaintainFrm.pas-------------对已保存的定制进行修改维护的单元文件 4)BrowserFrm.dfm----------浏览器的窗体文件 BrowserFrm.pas----------浏览器的单元文件 5)CustomSearchFrm.dfm-------实现定制搜索功能窗体文件 CustomSearchFrm.pas-----------实现定制搜索功能单元文件 6)DisplayFrm.dfm----------------设计显示和操作搜索信息界面的窗体文件 DisplayFrm.pas--------------设计显示和操作搜索信息界面的单元文件 7)DisplayFra.dfm------------显示的搜索到的网站的窗体文件 DisplayFra.pas------------显示的搜索到的网站的单元文件 8)InputFra.dfm--------------进行搜索前对一些基本输入控件处理的窗体文件 InputFra.pas---------------进行搜索前对一些基本输入控件处理的单元文件 9)RollingNewsFrm.dfm---------用于滚动新闻设置的窗体文件 RollingNewsFrm.pas---------用于滚动新闻设置的单元文件 10)SettingFrm.dfm-----------用于系统的设置的窗体文件 SettingFrm.pas-----------用于系统的设置的单元文件 11)SiteArrangementFrm.dfm---整理“站内搜索”子模块中用户设置的窗体文件 SiteArrangementFrm.pas---整理“站内搜索”子模块中用户设置的单元文件 12)SiteSearchFrm.dfm--------主要用于实现站内搜索的窗体文件 SiteSearchFrm.pas--------主要用于实现站内搜索的单元文件 13)SplashFrm.dfm-----------实现系统开始运行闪屏的窗体文件 13)SplashFrm.pas-----------实现系统开始运行闪屏的单元文件 14)ViewFra.dfm--------------设定查询数据库保存的搜索结果信息条件输入的窗体文件 ViewFra.pas--------------设定查询数据库保存的搜索结果信息条件输入的单元文件 15)ViewInfoFrm.dfm----------对数据库中信息查询的窗体文件 ViewInfoFrm.pas-----------对数据库中信息查询的单元文件 16)UnitSearch.pas-----------实现百度、新浪等搜索引擎线程定义的单元文件 以上是code文件夹的主要文件,也是本案例工程的所有代码文件,其中ChannelPlayer.dpr是工程文件,记录本工程的信息;其他的窗体都是在本系统程序使用时动态调用(各个文件的调用关系可以参考本书第一章实例分析与完善的概要模块设置部分)。code文件夹中其他文件是在程序编译运行时候有delphi7自动生成,用户可以不管。其中*.~后缀的文件是相应文件名的备份,它们也是由delphi7自动生成。 (三)source文件夹中dcu文件夹中保存的文件是程序在编译的时候生成的中间文件,它们都对应code文件夹中的每个*.pas单元文 件。 (四)source文件夹中exe文件夹的文件: ChannelPlayer.exe---是本项目工程运行是自动生成的可执行运用程序 (五)系统需求: 1. 硬件要求: 基本配置为: ¢ CPU:Intel Pentium II-class 300 MHz (Intel Pentium III-class 600 MHz recommended) 这表明需要至少300MHz的奔III处理器,笔者所使用的是雷鸟1G,应该说 性能还是可以的。 ¢ RAM:96MB(128MB recommended) 实际上,128M内存运行起来还是觉得不够,最好能够有256M以上内存。笔 者使用的是256M DDR内存。 ¢ Available hard disk space(for install):250MB ¢ Available hard disk space(post install):155MB 事实上,这个要求仅仅是针对安装delphi7所提出的 要求。 ¢ Video:800×600,256 colors 只要是14英寸显示器就可以达到这个要求。 ¢ CD-ROM:required 这只是目前计算机的标准配置,实际上,如果不是采用光盘安装的话,CD-ROM 根本就派不上用场。 ¢ Operating System:Microsoft Windows 2000(or up) ¢ Microsoft Internet Explorer 5.5(or up) 2. 本系统工程的开发环境 本信息搜索系统程序是在WindowsXP的Delphi7环境下开发编写的,并且通过测试。另外本系统也能在windows98,me,2000 的delphi7环境下开发编写。对于delphi的版本,虽然delphi6与delphi7相差不大,但由于本系统的网络部分用到的一些网络控件在delphi6没有,所以如果想使用delphi6编写的程序员要用delphi6的网络控件代替delphi7的网络控件。对于刚出的delphi8,由于它是基于net框架的,主要用于网页编写,编写应用程序的方式不一样,而且delphi7的很多控件都没有,所以一般不能在delphi8中开发运行(除非重新编写所有的代码)。 (六)注意事项: 本系统要注意开发环境的选取,如上面所说的,最好使用delphi7以下的版本,不能使用delphi8。另外还要注意系统程序所用到的数据库的设置,先是把数据库还原,然后设置TEST.UDL里的连接参数,使程序能与数据库建立关系。这样之后才能运行程序。最后,由于本系统是借助几大门户网站的搜索功能实现搜索,所以要注意这些门户网站的更新,根据它们的更新来更新本系统。 (七)技术支持信息: 本系统的运行与操作: 本系统在运行之前要先设置好与数据库的连接(参考第4章的实例分析与完善)。然后运行程序会出现一个主界面,界面中间是有关新闻的滚动。点击“定制搜索”功能可进入定制搜索界面,在界面的左边可以选择是搜索以前的关键字还是重新输入,如果重新输入着在“关键字”栏里填写关键字,然后选择相关设置就可以搜索。对于搜索到的信息可以直接单击进入网页,也可以右键点击选择不同的操作。保存搜索信息公能用于对本次搜索信息保存到数据库中。点击主界面的“查看信息”功能可以进入查看信息界面,其界面与定制搜索界面相识。 点击主界面的“滚动新闻”功能和“系统设置”功能可以设置主界面的新闻滚动和本系统的信息。 _________________________________________________________________ 技术支持的联系方式: 如果用户对于本系统程序有什么疑问可以发邮件到: hsw_gm@21cn.com tenny_2000@163.com sqwen@yeah.net kukocpoplee@tom.com Jingfei2000@21cn.com _________________________________________________________________

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值