|
The C# Column
Deploying .NET applications - II
(Continued from last week
)
Suppose
we wish to add a key-value pair to Hkey_Current_User | Software
| [Manufacturer]. For this we must right-click on it and select
New | Key. We can rename the key as per our wish. To add a value
we need to right-click on the newly formed key and select the type
of value we wish to add, i.e. whether it should be a String value,
a DWORD value, a Binary value, etc. We can set it to some value
using the Properties window. Now if we build winsetup and install
the application, the entry would be made in the registry. We can
verify this by executing the Registry Editor (RegEdit) through the
Start | Run dialog box.
Adding custom installation dialog boxes
Once the MSI file is built and we double-click on it, the installation starts.
The user is presented with five dialog boxes during installation. These dialog
boxes are predefined dialog boxes that get added to our project by default.
We can customise these dialogs or add new dialog boxes to our project using
the User Interface Editor. This editor can be opened by right-clicking on the
project in Solution Explorer and selecting View | User Interface.
The User Interface Editor shows a tree control containing two sectionsInstall
and Administrative Install. The Install section contains dialog boxes that will
be displayed when any end-user runs the installer. Administrative installation
is a feature of Microsoft Windows Installer that allows us to install a source
image of an application on a network share. Users in a workgroup who have access
to the network share can then install the application from the source image.
The User Interface Editor allows us to specify a different set of installation
dialog boxes that will be displayed when an administrator installs the application
to a network share via the command line as shown below:
Msiexec.exe /a Setup1.msi
This will start the installer of our application and dialog boxes specified
for the Administrative Install will be displayed.
The default set of predefined dialog boxes is displayed in the User Interface
Editor; we can rearrange or delete these if we wish. The default set of dialog
boxes varies according to the type of deployment project. Predefined dialog
boxes are divided into three categories:
Start dialog boxes are displayed before the installation begins. Commonly they
are used to gather customer information or to allow the user to change the installation
directory.
A progress dialog box is displayed to provide feedback on the progress of an
installation.
End dialog boxes are displayed once the installation has finished successfully.
Common uses are notifying the user that the installation is complete or to allow
the user to launch the application.
We can remove dialog boxes from the default set as per our wish or reposition
them using the right-click | Move Up/Move Down options. Note that all combinations
are not possible here. For example, we cannot remove the Progress dialog box
and place it in the Start dialog boxes category after the Welcome dialog box.
Now in addition to these dialog boxes we can add and configure our own custom
dialog boxes that get displayed during the installation. To do so we need to
right-click on the desired category and select Add Dialog. On doing
so the Add Dialog Box gets displayed.
Here we are presented with several ready-made dialog boxes that we may want
to display during installation. The following table indicates the use of these
dialog boxes.
Out of the several dialog boxes listed in this table we will discuss only the
ones that are likely to be used more commonly. These include the Checkbox, Read
Me, and the Splash dialog boxes.
| Dialog box |
Purpose |
| RadioButtons (2 buttons) |
Gives the user a choice between two options through
two radio buttons. |
| RadioButtons (3 buttons) |
Gives the user a choice between three options through
three radio buttons. |
| RadioButtons (4 buttons) |
Gives the user a choice between four options through
four radio buttons. |
| Checkboxes A, B, or C |
Gives the user a choice to add 1, 2, 3 or 4 checkboxes
in the same dialog |
| Customer Information |
Used to retrieve information including name, company,
and serial number. |
| Textboxes A, B, or C |
Used to retrieve custom information using 1, 2 or
3 text boxes. |
| License Agreement |
Displays a license agreement for the user to read
and acknowledge. |
| Read Me |
Allows the user to view any Read me file in .rtf
format. |
| Register User |
Allows the user to submit registration information. |
| Splash |
Displays a Splash Screen in .bmp format during installation. |
Suppose during installation we plan to ask the user whether he wants to add
the Disclaimer.txt file along with windowsapp1.exe or
not. To control this we plan to add the Checkbox dialog box. If the user checks
the Checkbox, the text file gets installed. To add this custom dialog box we
have followed the same steps discussed above and added the Checkboxes (A) Dialog.
This dialog box gets added as the last dialog box of the Start dialog boxes
category. So we can move it up by two positions. Next we have changed some properties
of the Checkboxes (A) dialog box. These are shown in the following table.
| Property |
Changed to
|
| BannerText |
Disclaimer |
| BodyText |
Do you want to install the Disclaimer text file? |
| Checkbox1 Label
|
Install Disclaimer |
| Checkbox1 Value
|
Unchecked |
| Checkbox1 Visible
|
True |
| Checkbox2Visible
|
False |
| Checkbox3Visible
|
False |
| Checkbox4Visible |
False |
Note that we have changed the visible property of the remaining checkboxes
to false because we need just one checkbox. Now we need to add a folder in the
Application Folder named Disclaimer. For this we must right-click on the Application
Folder and select Add | Folder. This adds a new folder, that we
rename to Disclaimer.
Next we add a text file called Disclaimer.txt
to this folder. Hence the Application Folder would contain the windowsapp1.exe
along with the Disclaimer folder holding the Disclaimer.txt file.
Then comes the most important step of setting the Condition property of the
Disclaimer.txt file so that it only gets installed when the checkbox
is checked. To do this we need to open the Properties Window of the Disclaimer.txt
and set its Condition property to CHECKBOXA1=1. On building the winsetup.msi
project, and double-clicking it, we are presented with this dialog box in the
second step of the installation process. The Disclaimer dialog box is shown
in the following figure.
This
dialog box displays the Read Me file during the installation procedure and installs
it along with the application. To demonstrate this we must add the Read Me dialog
box in the Start dialog boxes category. Next we need to associate a Rich Text
File (rtf) with this dialog box. For this we have to create a ReadMe.rtf
file and add it to the Applications Folder. Next we have to set the ReadmeFile
attribute of the Read Me dialog box to this file. We can browse for this file
and since we had added it to the Applications Folder we will find it there.
Note that we cannot browse beyond the three folders (Application Folder, Users
Program and Users Programs Menu), hence if we wish to make any file available
in the project we have to first get it copied in one of these. Now after re-building
the project and installing it we are presented with this Read Me dialog box
as the 5th step of installation and this file gets copied along with the folder.
We
add the Splash dialog box just after the Welcome dialog box. The User Interface
Editor, after addition of all the dialog boxes, is shown in the following figure.
To display a splash screen in the Splash dialog box, all
we need to do is to set the SplashBitmap property of the dialog to a .bmp
file. To make the file available we must first add it to the Application Folder.
On re-building this project and running the installer we are presented with
the Splash dialog box.
In the next part we will see how to add launch conditions
to the setup project.
 |
Yashavant Kanetkar, one of
the first Express Computer columnists, is an established software
expert, speaker and author with several best-sellers to his
credit, including titles like “Let Us C” and the “Fundas” series.
Contact him at kanetkar@dcubesoft.com |
|