Click here to Skip to main content
15,888,202 members
Articles / Programming Languages / C++
Article

How to create customized InstallShield for a VC++ Application

Rate me:
Please Sign up or sign in to vote.
2.46/5 (21 votes)
23 Mar 20048 min read 159.9K   42   33
This article basically talks about InstallShield for VC++ applications.

Introduction

This document explains some simple methods to create a customized installation program with the "limited InstallShield which is supplied with VC++ 6.0", for VC++ Applications.

Finding Dependencies of Distributing Application

Before creating the Install Shield for our Release version of the application, we should be aware about the list of DLLs and OCXs that our application is dependent on. That is, we should know about the dependent files our application needs to run in another machine. You can easily find the dependent files by debugging the application after setting the project to Debug mode. While you're running the application, the dependencies will be listed in the debug output window. Don't forget to do "Rebuild All" before distributing an application. While installing our application, those files need to be placed into the destination machine's Windows System directory or wherever it is needed.

Steps to create Install Shield

  1. Install "InstallShield for Visual C++" from the CD.
  2. Run Install Shield for Microsoft Visual C++ 6.
  3. Start Project Wizard (Choose "File, New").
  4. Enter the information in the Welcome Screen.

    Information about Application Name, Company Name, Development Environment, Application Type, Application Version, and Application Executable.

  5. Select Dialogs in Choose Dialogs Screen.

    Use the checkbox to select and deselect the Dialogs which you want to use in the Setup.

  6. Choose target platform.

    (Fill it in with the relevant details and click "Next", if you're not sure then accept the defaults.)

  7. Specify language.

    (Fill it in with the relevant details and click "Next", if you're not sure then accept the defaults.)

  8. Specify Setup Types.

    (Fill it in with the relevant details and click "Next", if you're not sure then accept the defaults.)

  9. Specify Components.
  10. (Fill it in with the relevant details and click "Next", if you're not sure then accept the defaults.)
  11. Specify File Groups.

    (Fill it in with the relevant details and click "Next", if you're not sure then accept the defaults.)

  12. Summary.

    The final dialog is the summary dialog, review the data, and if necessary, use the Back button to go and make changes you want. Press Finish button to create script file for your setup when you have finished everything. The Install Shield scripting language is a mix of C and Basic.

Now, we have a script file named Setup.rul, and "Project Workspace" window on left side describing the summary of files and folders which we had for our application setup. We can easily add files and directory to our application using this wizard. Select "File Groups" tab for including files. Open Program Executable File Directory and click on the Link node. You can include file and directory to this program executable link by right clicking the pane on the right hand side. You can also replace the setup image by replacing setup.bmp with another modified file of the same format, and name from Language Independent under Splash Screen node in Setup Files tab. Like that, you can also replace the license file from the Operating System Independent under Language Independent of Setup Files tab.

You can easily customize the setup by writing codes in script file. The help provided by Install Shield explains the built-in functions. You can easily find these functions by just right clicking on the script file and by selecting the Function wizard. Some of the commonly used methods are listed below.

Modify Back Ground Color of the Install Shield's Screen.

SetColor(BACKGROUND, BK_SMOOTH | RGB(15,75,175));
Enable( BACKGROUND );

By changing the value of RGB, you can easily modify the color.

Get System Information

STRING svResult;

NUMBER nvResult;
GetSystemInfo (nItem, nvResult, svResult);

To get information about base memory:

GetSystemInfo (BASEMEMORY, nvResult, svResult);

nvResult: the numeric value will be returned in this parameter and alphanumeric will be returned in the svResult parameter. nItem specifies the information you want to retrieve from the target machine which is an in-built constant like CD-ROM.

Create Registry Entry

RegDBSetDefaultRoot( HKEY_CURRENT_USER );

szKey = "SOFTWARE\\" + "MyApp Inc.";
RegDBCreateKeyEx( szKey, "" );

RegDBSetKeyValueEx( szKey, "Version",  REGDB_BINARY, "1.1", -1 );

RegDBSetDefaultRoot function is used for setting a different key root. RegDBCreateKeyEx and RegDBSetKeyValueEx are used for creating and assigning values for a key.

Security Checking

if ( !Is(USER_ADMINISTRATOR , "") ) then
    MessageBox ("You do not have administrator privileges,
      Contact an administrator to install this Application.", SEVERE );
    abort;
endif;

This method is used to retrieve commonly used information.

User Interactive Methods

MessageBox ( szMsg , INFORMATION );

This method is simply working as alert box for the user, szMsg is a string variable containing the message, and the second parameter specifies the type of message it contained whether it is INFORMATION, WARNING etc.

STRING svResult;

STRING svDeault;
svDeault="24";

AskText ("What is ur Age", svDeault, svResult );

This method is working as a prompt where svDeault contains the default value and svResult will return the output.

How can we add access to the application through the start menu?

Locate the function SetupFolders(). And add the following code into it:

function SetupFolders()
  NUMBER nResult;
  STRING svPath;
  begin
    svPath = TARGETDIR ^ "MyApp.exe";
    LongPathToQuote ( svPath , TRUE );
    AddFolderIcon ( FOLDER_STARTMENU, "My App", 
        svPath , "" , "" , 0 , "" , REPLACE );
    nResult = CreateShellObjects( "" );
    return nResult;
  end; 

where TARGETDIR contains the path of the executable after installation (path of MyApp.exe). You can create a shortcut by replacing FOLDER_STARTMENU value in the AddFolderIcon method with FOLDER_DESKTOP. Also, accessing the application through "Program files" option in "Start" menu can be done by replacing the same with FOLDER_PROGRAMS.

Creating a custom Input Dialog box

  1. Defining of method ChooseUserOption()
    prototype ChooseUserOption();
    

    Here, we define our user defined method in the script file.

  2. Defining method for option dialog
      function ChooseUserOption()
    
        NUMBER nResult, nType; 
        NUMBER nvCheck1,nvCheck2,nvCheck3; 
        STRING szTitle, szMsg; 
     begin 
      
     nResult = AskOptions ( EXCLUSIVE , "Which Installation U need?" , 
      "Option 1" , nvCheck1 , "Option 2" , nvCheck2 , "Option 3" , nvCheck3); 
      
     if(nvCheck3 == 1) then 
         MessageBox ( "Third Option Clicked!" , INFORMATION ); 
      
     endif; 
      
     if(nvCheck2 == 1) then 
         MessageBox ( "Secound Option Clicked!" , INFORMATION ); 
     endif; 
      
     if(nvCheck1 == 1) then 
         MessageBox ( "First Option Clicked!" , INFORMATION ); 
     endif; 
      
    return nResult;
    end;

    This AskOptions() method displays a dialog box containing option for selecting different values. You can have checkbox or radio button depending on the first parameter. If the parameter is EXCLUSIVE, this radio button will be displayed, and if it is NONEXCLUSIVE, checkbox will be displayed. The second parameter is the text to be displayed in the dialog box as a question or message for the user. The third and fourth parameters are text to be displayed with the first control and its return value respectively. You can display up to a maximum of nine options using this function.

  3. Modification for Next and Back buttons
     Dlg_SdLicense:
        nResult = DialogShowSdLicense();
        if (nResult = BACK) goto Dlg_SdWelcome;
    
    Dlg_SdChooseUserOption:
        nResult = ChooseUserOption();
        if (nResult = BACK) goto Dlg_SdLicense;
    
    Dlg_SdRegisterUserEx:
        nResult = DialogShowSdRegisterUserEx();
        if (nResult = BACK) goto Dlg_SdChooseUserOption;
    

    This code is done for navigation between dialog boxes. For my case, I showed my ChooseUserOption dialog box after License dialog box, so my Back button should point to the License dialog. In a similar manner, RegisterUserEx is shown after ChooseUserOption, so the Back button of that dialog box should point to my ChooseUserOption dialog.

Inclusion of Self-Registering Files

Put the self-registering executable files in a file group with the Self-registered and Shared properties set to Yes. And include this file group into one of the components in your application setup. By double clicking the Include file group option in the right pane of the window, you can easily add file groups into that. You can also specify the destination place of the included file in the same window using the Destination option. After that, add the following code into the script file.

Search for the function MoveFileData() and before you call ComponentMoveData() function, call Enable(SELFREGISTERBATCH). Also find function ProcessAfterDataMove() and call: Do(SELFREGISTRATIONPROCESS). This SELFREGISTERBATCH registers all components after copying all files to the system. If the executable is not registered, then the Do function will return -1.

UnInstallation

The UnInstallShield executable is automatically included in your setup when you run the Media Build Wizard. The key path will be like this.

[HKEY_LOCAL_MACHINE]\Software\Microsoft\
  Windows\CurrentVersion\Uninstall\<application uninstallation key>

Handling UnInstallation through Program menu using UnInstallShield

Uninstallation is handled by launching UnInstallShield under the Program Manager shell. The uninstallation expression is the same expression that is assigned to the [UninstallString] value under the application uninstallation key in the Registry. An example of uninstallation command expression is like the following:

C:\WINNT\IsUninst.exe -fC:\WINNT\Uninst.isu

We can easily copy the string from the Registry and can be executed using the Run option in the Windows start menu.

STRING svUninstLogFile;
STRING szProgram;
STRING svUnInIconPath;
   svUninstLogFile = TARGETDIR ^ "Uninst.isu";
   szProgram = UNINST + " -f\"" + svUninstLogFile+"\"";
   AddFolderIcon(FOLDER_PROGRAMS ^ "LeapMe 2.1", 
      "My Uninstall", szProgram, WINDIR, 
      svUnInIconPath, 0, "", REPLACE);

Here Uninst.isu is the file created for uninstallation by the InstallShield wizard and TARGETDIR is the root path where the setup is installed. UNINST is a system variable, which contains the full path and file name of the UnInstallShield executable file. AddFolderIcon is called to add the uninstaller icon to the application's program folder, and the target program value is also assigned to it. In the above example, I used the " with the escape character to solve the problem of space in the file name or folder name.

Creating Media

For checking syntax errors, you can use the Build menu, and select Compile, or click Compile button. If there is no compile time error, use the Build menu, and select "Media Build Wizard", or click the "Media Build" button for creating Media. It is possible to change the media name from the first dialog box. That is, it's possible to change the name from "New Media" to something else. Click "Next" and proceed to the next dialog. In this one, you decide which Media Type to use. For small applications, we will select 3.5" Diskette and 1.44 Mbytes. For bigger application, we have to use CD-ROM 650. Click "Next", then choose "Full Build" if the wizard has not already selected it. In the next dialog, it is possible to insert your company name, version info etc. Next, we have to select which platforms the application is for, choose platforms which are relevant for your case. The final dialog is the summary dialog; review the data, and if necessary, use the Back button to go and make any changes you want. When you are done, click "Finish".

In my case, the files built were placed in "C:\My Installations\MyApp\Media\MyApp\Disk Images\Disk 1", or you can copy the setup to some other directory using Send Media To from the Build menu. You can now take all the files found in this disk1 directory and copy them to a floppy disk or CD depending on the size you selected above, and use that to install from. You can test the setup by executing the "setup" exe file found there.

Conclusion

The main purpose of this article is to show you how to make a simple installer for a VC++ application. InstallShield comes free with VC++ 6.0. You can visit the InstallShield website and register your copy, or buy a new version. They also provide technical support. There are lots of installer software available in the market. Comparative studies of various installer software can be found in the above said web site.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
Jimmy M Joy - Microsoft Application Developer

Comments and Discussions

 
Questionset up creation Pin
iampradeepsharma7-Nov-12 16:38
iampradeepsharma7-Nov-12 16:38 
QuestionApplication to run on single client system? Pin
Andy Rama4-Aug-08 21:21
Andy Rama4-Aug-08 21:21 
QuestionHow to uninstall the old version and then install the new version automatically by IS 2008? Pin
joshlin23-Jul-08 18:01
joshlin23-Jul-08 18:01 
GeneralInstaller that automatically install specific software before the main software Pin
Md. Mazharul Islam Khan9-Apr-08 23:13
Md. Mazharul Islam Khan9-Apr-08 23:13 
GeneralRe: Installer that automatically install specific software before the main software Pin
joshlin23-Jul-08 17:46
joshlin23-Jul-08 17:46 
GeneralMS Flex Grid Pin
samdu112527-Oct-07 0:52
samdu112527-Oct-07 0:52 
GeneralMS Flex Grid Pin
samdu112527-Oct-07 0:52
samdu112527-Oct-07 0:52 
GeneralSetup Pin
samdu112527-Oct-07 0:44
samdu112527-Oct-07 0:44 
Questionwhat is mean by unistallerff Pin
yadahav23-Sep-07 20:09
yadahav23-Sep-07 20:09 
Questionhow can i do this with vc++.net compiler Pin
rajbhansingh24-Jul-07 22:11
rajbhansingh24-Jul-07 22:11 
Questionhi Pin
uma.bathula8-Mar-07 19:29
uma.bathula8-Mar-07 19:29 
GeneralNeed help Pin
longtaildragon17-Mar-06 2:49
longtaildragon17-Mar-06 2:49 
GeneralRe: Need help Pin
Jimmy M Joy17-Mar-06 7:00
Jimmy M Joy17-Mar-06 7:00 
GeneralRe: Need help Pin
longtaildragon22-Mar-06 2:57
longtaildragon22-Mar-06 2:57 
GeneralRe: Need help Pin
Jimmy M Joy22-Mar-06 11:10
Jimmy M Joy22-Mar-06 11:10 
GeneralRe: Need help Pin
longtaildragon1-Apr-06 21:28
longtaildragon1-Apr-06 21:28 
GeneralExtending your Installer Program. Pin
gabgar4-Feb-06 16:37
gabgar4-Feb-06 16:37 
GeneralInstalling Windows Services Pin
Noch21-Dec-04 22:34
Noch21-Dec-04 22:34 
GeneralActiveX controls and dlls Pin
pc_dev23-Nov-04 19:25
pc_dev23-Nov-04 19:25 
GeneralInstallShield Stringtable Pin
juergen.althans21-Sep-04 4:37
juergen.althans21-Sep-04 4:37 
GeneralDumb question, but... Pin
otrcomm14-Jul-04 6:18
otrcomm14-Jul-04 6:18 
QuestionHow to create Install shiled .i have created setup ,but it is not creating exe in Startup menu Pin
Anonymous22-Mar-04 19:05
Anonymous22-Mar-04 19:05 
AnswerRe: How to create Install shiled .i have created setup ,but it is not creating exe in Startup menu Pin
Jimmy M Joy23-Mar-04 17:51
Jimmy M Joy23-Mar-04 17:51 
GeneralI Use NSIS Pin
Konrad Windszus28-Jan-04 7:53
Konrad Windszus28-Jan-04 7:53 
GeneralRe: I Use NSIS - WOW Pin
YoSilver28-Jan-04 8:43
YoSilver28-Jan-04 8:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.