Write installer with Delphi (1)

zhaozj2021-02-11  228

Write installer with Delphi (1)

[Author: Yu Wen group Add Time: 2001-5-5 18:01:08]

Once you have completed an application development, then you need to make a standardized installer for the software, which is the final step of the program design, and it is also important to step, because running installer is often the first Step.

Many newspapers include how many tool software such as InstallShield is used to make installation methods. This method can quickly establish a more common installation mode, but there are some shortcomings in this way, such as the installer made. Big; style is more single; unable to control the start-up mode and shortcut. In fact, several running steps of the installer are more fixed, we can write installs themselves. The following details how to write a installer with your own software features with Delphi.

Several principles needed to install programs, such as the disposition of the configuration, etc., there are many articles in the relevant magazines, no longer be described. Here mainly introduces several main processes in the installation program:

1. Procedures that will be installed into resource files

Step 1: Write the Myres.rc resource script file, which can be written with 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: Compiles to generate resource files.res.res.Res with BRCC32.

Brcc32.exe myres.rc

2. Write installer code

Step 1: Add {$ r mymyres.res} statement in the setup.dpr file, which contains the resource file when compiling files.

Step 2: Write the installer background interface.

// Interface color gradient effect is achieved by sequentially adjacent rectangular blocks by a gradient brush brush.

// You can also implement the installation interface for other special effects.

Var i, J: integer;

DCT: TRECT;

Begin

Form1.windowState: = wsmaximized;

J: = form1.width;

// Get the height of the form

For i: = 0 to 255 do

// Set a color value in RGB () here

Begin

Canvas.brush.color: = RGB (0,0,255-i);

/ / Draw a rectangular brush color (left, up, right, and right) each time

// DCT: = RECT (i * 2, 0, (i 1) * 2, j);

DCT: = RECT (0, i * 2, j, (i 1) * 3);

// Rectangular area each time you brush

Canvas.FillRect (DCT);

Form1.canvas.TextRect (DCT, 30, 40, 'Ningbo University Courseware Management System V1.0');

// Pack color

END;

END;

Step 3: Create a main program work directory

/ / Set the directory environment and configuration file

If not directoryexists (edtdir.text) THEN

// if messagebox (getfocus, 'This directory does not exist, is it created?', 'Inquiry', 1) = idok then

Try

Forcedirectories (EDTDIR.TEXT);

转载请注明原文地址:https://www.9cbs.com/read-3878.html

New Post(0)