How to Modify SetupKit to Install New Icon & Working Directory (114774)



The information in this article applies to:

  • Microsoft Visual Basic Standard Edition for Windows 3.0
  • Microsoft Visual Basic Professional Edition for Windows 3.0

This article was previously published under Q114774

SUMMARY

Using the Visual Basic Setup Toolkit, you can modify the setup program that was created by Setupwizard.

The example shown below modifies your setup program to install a separate icon and default working directory for your program. You can do this by changing the SETUP1A.FRM and SETUP1.BAS source code. You can then make a new SETUP1.EXE file and new SETUP1.EX_ file on your distribution disk.

For additional information regarding the updates and other modifications you can make to the SetupKit, please see the following articles in the Microsoft Knowledge Base:

110395 : How to Modify Destination Directory of Setupwizard SETUP1.EXE

100003 : UPD: New Setup Toolkit & Setup Wizard Available for VB ver 3.0

MORE INFORMATION

Step-by-Step Example

The following step-by-step example, is based on an example developed by Jim St. John:
  1. Run the Setupwizard to create the master distribution disks for your product's files. Be sure to include the icon file you want to assign to your program.
  2. Start Visual Basic and open the SETUP1A.MAK project. SETUP1A.MAK is already on the most recently opened list on the File menu because the Setupwizard used it once. The Setupwizard created the SETUP1A.MAK project in the C:\VB\SETUPKIT\SETUP1 directory.
  3. Go to the CreateProgManItem subroutine for the SETUP1.BAS module to add parameters to the declaration of the subroutine and to modify one of the LinkExecute lines. Here's the changed code:
    '----------------------------------------------------------
    ' Procedure: CreateProgManItem
    '
    ' Arguments: X           The form where Label1 exists
    '
    '            CmdLine$    A string that contains the command
    '                        line for the item/icon.
    '                        ie 'c:\myapp\setup.exe'
    '
    '            IconTitle$  A string that contains the item's
    '                        caption
    '----------------------------------------------------------
    
    Sub CreateProgManItem (x As Form, CmdLine$, IconTitle$)
        ...
        ' Enter the following two lines as one, single line:
        x.Label1.LinkExecute "[AddItem(" + CmdLine$ + Chr$(44) + IconTitle$ +
           Chr$(44) + ",,)]"
        ...
    End Sub

    To add a separate icon and default working directory, modify the above lines to read as follows:
    '----------------------------------------------------------
    ' Procedure: CreateProgManItem
    '
    ' Arguments: X           The form where Label1 exists
    '
    '            CmdLine$    A string that contains the command
    '                        line for the item/icon.
    '                        ie 'c:\myapp\setup.exe'
    '
    '            IconTitle$  A string that contains the item's
    '                        caption
    '
    '            IconPath$   A string that contains the filename
    '                        for the icon to be displayed in the
    '                        group window
    '
    '            IconIndex   Specifies the index of the icon in
    '                        the file indicated by the IconPath$
    '                        parameter
    '                        -1 for default icon
    '
    '            xPos        Specifies the horizontal position
    '                        of the icon in the group window
    '                        -1 for next icon in group
    '
    '            yPos        Specifies the vertical position
    '                        of the icon in the group window
    '                        -1 for next icon in group
    '
    '            DefDir$     A string that contains the name of
    '                        the default (or working) directory
    '                        Win 3.1
    '
    '            HotKey      Identifies a hot (or shortcut) key
    '                        that is specified by the user
    '                        Win 3.1
    '                       NOTE: For the HotKey parameter, specify the ASCII
    '                       value of the desired key. The application can
    '                       create a key combination (for example, ALT+SHIFT+A)
    '                       by adding one or more of the following values to
    '                       the ASCII value for the key:
    '
    '                                        Decimal
    '                          Key           Offset
    '                          ---           ------
    '                          SHIFT            256
    '                          CTRL             512
    '                          ALT             1024
    '
    '                       For example, ALT+SHIFT+A is signified by 1345
    '                       (1024+256+65).
    '
    '            fMinimize   Specifies whether an application
    '                        should be minimized when it is
    '                        first displayed
    '                        Win 3.1
    '
    '----------------------------------------------------------
    
    ' Enter the following two lines as one, single line:
    
    Sub CreateProgManItem (x As Form, CmdLine$, IconTitle$, IconPath$,
       IconIndex, xPos, yPos, DefDir$, HotKey, fMinimize)
       Dim sParam As String
       ...
       ' Add the following lines in place of the single LinkExecute line above
       sParam = CmdLine$ + "," + IconTitle$
       sParam = sParam + "," + IconPath$ + ","
       If IconIndex >= 0 Then sParam = sParam + Format$(IconIndex)
       sParam = sParam + "," + Format$(xPos) + "," + Format$(yPos)
       If gfWin31% Then ' Win 3.1 - additional parameters allowed
          sParam = sParam + "," + DefDir
          sParam = sParam + ","
          If HotKey Then sParam = sParam + Format$(HotKey)
          sParam = sParam + ","
          If fMinimize Then sParam = sParam + Format$(fMinimize)
       End If
       x.Label1.LinkExecute "[AddItem(" + sParam + ")]"
       ...
    End Sub
  4. From the File menu, choose Save File As, and change the name of the file from SETUP1.BAS to SETUP1A.BAS. Now, you can use this modified version in later distributions of your product.
  5. Modify where you call CreateProgmanItem. Locate the following line of code in the Form_Load event of SETUP1A.FRM:
       CreateProgManItem Setup1, destPath$ + "<your>.EXE", "your title"
    
       Change it to read:
    
       ' The following installs your program's icon setting it to be used
       ' from the the destination directory. It also sets the default working
       ' directory as the windows directory.
       ' Enter the following two lines as one, single line:
       CreateProgManItem Setup1, destPath$ + "<your>.EXE", "your title",
          destPath$ + "your.ico", -1, -1, -1, winDir$, 0, 0
    
  6. Modify the line that installs the ODBC administrator. Locate the line that reads:
      CreateProgManItem Setup1, destPath$ + "ODBCADM.EXE", "ODBC Administrator"
    
    Change it to read:
      ' Enter the following three lines as one, single line:
      CreateProgManItem Setup1, destPath$ + "ODBCADM.EXE",
         "ODBC Administrator", destPath$ + "ODBCADM.EXE", -1, -1, -1,
         destPath$, 0, 0
    
  7. From the File menu, choose Save Project to save all the changes.
  8. From the File menu, choose Make EXE File to re-create the file SETUP1.EXE in the C:\VB\SETUPKIT\SETUP1 directory.
  9. Compress and copy this new SETUP1.EXE file to your distribution disk. For example, the following command at the MS-DOS prompt compresses SETUP1.EXE into SETUP1.EX_ and copies SETUP1.EX_ to Drive A:

    C:\VB\SETUPKIT\KITFILES\COMPRESS -r SETUP1.EXE A:\

    This replaces the old SETUP1.EX_ created on the distribution disk by the Setupwizard.

Modification Type:MajorLast Reviewed:10/29/2003
Keywords:kbcode KB114774