After you complete the development of an application software, you also need to make a standardized installation program for the software. This is the last step in program design, and it is also a very important step, because running the installation program is often the first thing that users do. step operation.
Many newspapers and periodical articles have introduced many methods on how to use installshield and other tool software to create installation programs. This method can quickly establish a more common installation mode, but there are some shortcomings in this method. For example, the installation program is generally relatively small. Large; single style; unable to flexibly control startup methods and shortcuts. In fact, several running steps of the installation program are relatively fixed, and we can write the installation program ourselves. The following is a detailed introduction on how to use DELPHI to write an installation program with its own software characteristics.
Several principles that the installation program must achieve, such as one-time configuration, etc., have been introduced in many articles in relevant magazines, so I will not repeat them here. Here we mainly introduce several main processes in writing the installation program:
1. Make the programs that need to be installed into resource files
Step 1: Write the myres.rc resource script file, which can be written in Notepad.
MYDBSRC mydbsrcfile c:esdemomynbdb.mdb
MYDBJET mydbjetfile c:esdemomdac_typ.exe
MYDBAPP mydbappfile c:esdemoTnbdemo.exe
7001 Icon c: esdemosetup.ico
Step 2: Use BRCC32 to compile and generate the resource file myres.res.
brcc32.exe myres.rc
2. Write the installation program code
Step 1: Add the {$R mymyres.RES} statement to the setup.dPR file so that the resource file is included when compiling the file.
Step 2: Write the installation program background interface.
//The interface color gradient effect is achieved by painting adjacent rectangular blocks with a gradient brush.
//It is also possible to implement other installation interfaces with 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);
//Brush color for each rectangle drawn (left, top, right, bottom)
//Dct:=Rect(i*2,0,(i+1)*2,j);
Dct:=Rect(0,i*2,j,(i+1)*3);
//The rectangular area painted each time
Canvas.FillRect(Dct);
Form1.Canvas.TextRect(Dct,30,40,'Ningbo University Courseware Management System v1.0');
//fill color
end;
end;
Step 3: Create the main program working directory
//Set directory environment and configuration files
if not DirectoryExists(EdtDir.Text) then
// if MessageBox(getfocus,'This directory does not exist, do you want to create it?','Ask',1) = idOK then
try
ForceDirectories(EdtDir.Text);