Use Delphi to compile the installation program (1)

Source: Internet
Author: User

Use Delphi to compile the installation program (1)

[Author: Yu wenqun: 18:01:08]

After you complete the development of an application, you also need to create a standardized installation program for the software. This is the last step in program design and is also an important step, because running the installer is usually the first step.

Many newspapers and articles have introduced how to use tools such as InstallShield to create installation programs. This method can quickly establish a common installation mode, but there are also some shortcomings in this method, for example, the installation program is generally large; the style is relatively simple; the startup mode and shortcuts cannot be controlled flexibly. In fact, the running steps of the installer are relatively fixed. We can compile the installer by ourselves. The following describes in detail how to use Delphi to compile an installation program with its own software characteristics.

There are several principles to be achieved by the installation program, such as one-time configuration, which have been described in many articles in the relevant magazine. The following describes how to write the installation program:

1. Create the program to be installed as the resource source file
Step 1: Compile the Myres. RC resource script file, which can be written in notepad.

Mydbsrc mydbsrcfile C:/resdemo/mynbdb. MDB

Mydbjet mydbjetfile C:/resdemo/mdac_typ.exe

Mydbapp mydbappfile C:/resdemo/tnbdemo.exe

7001 icon C:/resdemo/setup. ICO

Step 2: Use brcc32 to compile and generate the resource file Myres. Res.

Brcc32.exe Myres. RC

2. Compile the installer code
Step 1: add the {$ R Myres. Res} statement to the setup. DPR file to include the resource file during file compilation.

Step 2: Compile the installation background interface.

// The color gradient effect of the interface is achieved by refreshing adjacent rectangular blocks with a gradient.

// Other installation interfaces with special effects can also be implemented.

VaR I, j: integer;

DCT: trect;

Begin

Form1.windowstate: = wsmaximized;

J: = form1.width;

// Obtain the form height

For I: = 0 to 255 do

// Set a color value in RGB ().

Begin

Canvas. Brush. Color: = RGB (0, 0, 255-i );

// Specifies the stroke color of each rectangle (left, top, right, bottom)

// DCT: = rect (I * 2, 0, (I + 1) * 2, J );

DCT: = rect (0, I * 2, J, (I + 1) * 3 );

// The area of the rectangle to be painted each time

Canvas. fillrect (DCT );

Form1.canvas. textrect (DCT, 'ningbo University courseware Management System v1.0 ');

// Fill color

End;

End;

Step 3: create the working directory of the main program

// Set the directory environment and configuration file

If not directoryexists (edtdir. Text) then

// If MessageBox (getfocus, 'this directory does not exist. Do you want to create this directory? ', 'Query', 1) = idok then

Try

Forcedirectories (edtdir. Text );

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.