The setting of Delphi program memory parameters

Source: Internet
Author: User
Tags ini odbc

We usually use a lot of software have some memory functions, such as Foxmail and Thebat and so on.

These software can automatically at startup when the last shutdown of the software in some states, such as the initial position of the window, the user in the software set some features (such as window style, horizontal or vertical arrangement, etc.), if you can let our program also has some of the features that can make our program look more professional: Here, I'll tell you how to make the application remember the window position of the last time it was closed, and the same as the last time it was started.

Since we want to keep the information, we must involve the storage problem. There are several ways to store data, you can write. ini or. inf files, you can also use the file classes provided by Delphi to customize a file, you can also use database interfaces (such as ODBC) to introduce a database file, FoxPro DBF and Access's. mdb are more common and can be written directly to the Windows registry. Writing. ini and. inf files do not have any security and are not suitable for Win95, remember in the 94, 95 in the Chinese Windows3.2 in a large number of the use of the. ini file, but after Windows95, Microsoft recommends that as much as possible to write the information into the registry. The use of ODBC words will give the program a lot of unnecessary trouble, such as will make the program more complex, need the corresponding DBMS driver support, if there is no corresponding data source driver, then the data source can not be used, there are security issues can not be a good solution.

It is recommended here to use the method of writing the registry. Because this method is very convenient, do not need too much extra overhead, the program is relatively simple, for the average user to find useful information in the registry than open the. ini file more trouble. Therefore, the security of the registry is slightly stronger than the. ini file.

Enables the application to remember the window position of the last time it was closed, as it was when it was first started. The general idea is this: when you close the program to record the end of this program information, write to the registry, the next time the program starts to read the relevant information in the registry, and assigned to the program.

The information that we need to record primarily for this program is the top,left,height,width when the window closes.

Note: To enable Delphi to operate the registry, you must include the registry unit.

The following are source programs and related comments:

unit Unit1;
   interface
   uses
   Windows, Messages,. . . . . . . ,registry;
   //包括registry单元
   type
   TForm1 = class(Tform)
   .
   .
   .
   public
   ww:Tregistry;
   //声明一个Tregistry对象,我们就通过ww来

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.