WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Generic Install Routine



;********************************************************************************************************************************
;** Setup.wbt - Multipurpose Setup tool
;** Adrian Hayes
;**
;**
;** Purpose: Install Programs according to the specifications in the Setup.Ini file.
;** Inputs:
;**      Setup.ini - Setup.ini must be in the same folder as the Setup.EXE (or included in the compiled file)
;**         It must contain:
;**         [Install] - Install section containing entries for:
;**                     InstallBMP   -   (optional) picture to display on installation dialog
;**                     ProgName      -   (required) Program name
;**                     ProgExeFile   -   (required) Program executable filename
;**                     SourceFile   -   (required) zip file containing all files that need to be installed
;**                                     (note: SourceFile can be named something other than *.zip but must be a valid zip file.)
;**                     Copyright   -   (optional) Copyright string
;**                     ProgVer      -   (optional) Program Version
;**                     Contact      -   (optional) Who are you? Who who? Who who? :-)
;**                     DebugMode   -   (Omit unless necessary) 1 or 0.
;**                                    Include the DebugMode INI entry only if you want to do a debugtrace.  See DebugMode Below.
;**
;**         [Folders]
;**                     TargetFolder - (required) The default installation folder.
;**
;**         [Files] -   (required) a list of all files that need to be installed to the Target folder.  These files
;**                     need to be included in your zipped SourceFile.  Use this format:
;**                     filename.ext="Plain text description of file"
;**
;**         [SysFiles] -a list of files to be installed to Windows system folder (e.g., c:\Windows\System32)
;**                     Include any necessary WinBatch Extenders here for your program.  That way you can compile your
;**                     program as a Small EXE and the Setup will copy the necessary WinBatch extender files to the
;**                     Windows System folder.  Use the same format as [Files]
;**
;**         [ShortCut] -Information about the shortcut created
;**                     DefaultProgrManGroup - (required) Which default Program Group in the Start > All Programs?
;**                     ShortCutName          - (required) Name of Shortcut .lnk file
;**                     IconFile               - Icon File name
;**
;** Compiling Notes:
;**         When compiling this Setup script, use the Large EXE option.  Make sure you select the Zipper Extender (wwzip34i.dll)
;**         in the compiler dialog.  Also include your Setup.ini file, Zipped source file, and Install BMP using the compiler
;**         "Other Files" button.  This will give you a single distributable Setup.exe file.
;**
;** Revisions:
;**         03.02.04   - Adrian H. Hayes
;**            1.1   - Modified for generic use
;**          11.25.03   - Adrian H. Hayes
;**            1.0   - Initial Version created
;**
;** Possible future updates:
;**         - ability to check file version and only overwrite if newer version
;**         - abillity to force an overwrite
;**         - ability to specify files to NOT overwrite
;**         - abliity to create registry entries from .INI file.
;**         - Uninstall program & writing entries to Add/Remove Programs
;********************************************************************************************************************************


IntControl(49, 1, 99, 0, 0) ; Set all dialog boxes to have System menu.  Close returns 99.

AddExtender("WWZIP34I.DLL")   ;; Zipper Extender



;***************************************************************************
;** Where am I?
;***************************************************************************
SetupExePath = IntControl(1004,0,0,0,0)
SetupHomeDir = FilePath(SetupExePath)

SetupIni = StrCat(SetupHomeDir, "Setup.INI")


;***************************************************************************
;** Set DebugMode Trace File - Requires line in Ini file for DebugMode
;** Copies path of trace file to clipboard for easy pasting into Start > Run.
;***************************************************************************
DebugMode = IniReadPvt("Install", "DebugMode", @FALSE, SetupIni)
If DebugMode
   Tempfile = FileCreateTemp("SET")
   FileDelete(Tempfile)
   TempPath = FilePath(Tempfile)
   Tempfile = FileRoot(Tempfile)
   Tempfile = StrCat(TempPath, Tempfile, ".txt")
   ClipPut(Tempfile)
   DebugTrace(DebugMode, Tempfile)
   DebugVar = "-------DEBUG MODE STARTED---------"
EndIf



;***************************************************************************
;** Functions for Progress Bars
;** From: Article W15470 on http://techsupt.winbatch.com
;***************************************************************************
PBS_SMOOTH = 1
PBS_VERTICAL = 4

#DefineFunction BarCreate(x,y,w,h,style,handle)
   user32=StrCat(DirWindows(1),"user32.dll")
   hinst=DllHinst("")
   Return DllCall(user32,long:"CreateWindowExA",long:512,lpstr:"msctls_progress32",lpstr:"",long:1073741824|268435456|style,long:x,long:y,long:w,long:h,long:handle,long:0,long:hinst,long:0)
#EndFunction

#DefineFunction BarGetPos(handle)
   WM_USER = 1024
   PBM_GETPOS = WM_USER + 8
   user32=StrCat(DirWindows(1),"user32.dll")
   Return DllCall(user32,long:"SendMessageA",long:handle,long:PBM_GETPOS,long:0,long:0)
#EndFunction

 #DefineFunction BarSetPos(handle,position)
   WM_USER = 1024
   PBM_SETPOS = WM_USER + 2
   user32=StrCat(DirWindows(1),"user32.dll")
   Return DllCall(user32,long:"SendMessageA",long:handle,long:PBM_SETPOS,long:position,long:0)
#EndFunction

#DefineFunction BarGetPos(handle,position)
   WM_USER = 1024
   PBM_GETPOS = WM_USER + 8
   user32=StrCat(DirWindows(1),"user32.dll")
   Return DllCall(user32,long:"SendMessageA",long:handle,long:PBM_GETPOS,long:0,long:0)
#EndFunction

#DefineFunction BarSetRange(handle,low,high)
   WM_USER = 1024
   PBM_SETRANGE32 = WM_USER + 6
   user32=StrCat(DirWindows(1),"user32.dll")
   RANGE=BinaryAlloc(8)
   BinaryPoke4(RANGE,0,low)
   BinaryPoke4(RANGE,4,high)
   val = DllCall(user32,long:"SendMessageA",long:handle,long:PBM_SETRANGE32,long:low,long:high)
   BinaryFree(RANGE)
   Return val
#EndFunction

#DefineFunction BarSetStep(handle,step)
   WM_USER = 1024
   PBM_SETSTEP = WM_USER + 4
   user32=StrCat(DirWindows(1),"user32.dll")
   val = DllCall(user32,long:"SendMessageA",long:handle,long:PBM_SETSTEP,long:step,long:0)
   Return val
#EndFunction

#DefineFunction BarStepIt(handle)
   WM_USER = 1024
   PBM_STEPIT = WM_USER + 5
   user32=StrCat(DirWindows(1),"user32.dll")
   val = DllCall(user32,long:"SendMessageA",long:handle,long:PBM_STEPIT,long:0,long:0)
   Return val
#EndFunction

#DefineFunction BarSetBarColour(handle,colour)
   WM_USER = 1024
   PBM_SETBARCOLOR = WM_USER + 9
   user32=StrCat(DirWindows(1),"user32.dll")
   val = DllCall(user32,long:"SendMessageA",long:handle,long:PBM_SETBARCOLOR,long:0,long:colour)
   Return val
#EndFunction

#DefineFunction SetColour(red,green,blue)
  Return ((red mod 256)+(green mod 256)*256+(blue mod 256)*256*256)
#EndFunction

;***************************************************************************
;** Define variables for Dialog Events
;***************************************************************************
cDialogINIT            = 0   ; Dialog has been created but not displayed.
                           ;   This event is only generated once pre dialog session.
cDialogTIMER         = 1   ; Set a Timer event.
                           ;   (i) > 0 - milliseconds between callbacks
                           ;   0 - turn off timer;
                           ;   -1 - return current setting
cDialogBUTTON         = 2   ; User has pressed a PUSHBUTTON or PICTUREBUTTON control.
                           ;   (i) 1 - turn on event callback
                           ;   0 - turn off callback
                           ;   -1 - return current setting
cDialogRADIO         = 3   ; User has selected a RADIOBUTTON.
cDialogCHECKBOX      = 4   ; User has checked or unchecked a CHECKBOX control.
cDialogEDITMULTIBOX   = 5   ; User has changed the text in an EDITBOX or MULTILINEBOX control.
cDialogFILELISTBOX   = 6   ; User has selected a file in a FILELISTBOX control.
cDialogITEMBOX         = 7   ; User has selected one or more items in a ITEMBOX control.
cDialogCOMBOBOX      = 8   ; User has changed the text appearing at the top of a DROPLISTBOX.
                           ;   This event can be triggered by the user picking a new item from the list portion of the control
                           ;   or by the user typing new text into the control.
cDialogCALENDAR      = 9   ; User has selected a new date in a CALENDAR control.
                           ;   Note: cycling the month with the right and left arrows
                           ;   does not produce a callback. The user must click on a
                           ;   specific day of the month.
cDialogSPINNER         = 10   ; User has changed the value of a SPINNER control.
cDialogCLOSE         = 11   ; User has selected the Close command from the system menu.
                           ;   This event only applies to dialog's with system menus
                           ;   enabled by a call to IntControl 49.
cDialogFILBOXDCLK      = 12   ; The user has used the mouse to double-click an item in an FILELISTBOX.
cDialogITEMBOXDCLK   = 13   ; The user has used the mouse to double-click an item in an ITEMBOX
cDialogDISABLE         = 1000; Grey the dialog's title bar and redraw dialog as necessary.
                           ;   Optionally, display the system's "wait cursor".
                           ;   (i) 1 - disable dialog
                           ;   2 - disable and wait cursor
                           ;   0 - enable dialog
                           ;   -1 - return current setting.
cDialogCHGBACKGRND   = 1001; Change the dialog's background bitmap or color.
                           ;   (s) bitmap file name or RBG color string(i)
                           ;   -1 - return current background.
;***************************************************************************
;** DialogControlGet(dialog-handle,  control-number, request-code)
;***************************************************************************
DCGET_VALUE            = 1
DCGET_RADIO            = 2
DCGET_TEXT            = 3
DCGET_TITLE            = 4
DCGET_ITEMLIST         = 5
DCGET_ITEM            = 6
DCGET_CALENDAR         = 7
DCGET_SPINNER_VALUE   = 8
;***************************************************************************
;** DialogControlSet(dialog-handle, control-number, set-request-code, set-info)
;***************************************************************************
DCSET_VALUE            = 1
DCSET_RADIO_SELECTED = 2
DCSET_REPLACE_TEXT   = 3
DCSET_REPLACE_TITLE   = 4
DCSET_REPLACE_LIST   = 5
DCSET_ITEM_SELECTED   = 6
DCSET_CALENDAR         = 7
DCSET_SPINNER_VALUE   = 8
DCSET_PICTURE         = 12
DCSET_REPLACE_BITMAP   = 12
DCSET_TEXT_COLOR      = 13
DCSET_ADD_ITEM_SORT   = 14
DCSET_REMOVE_ITEM      = 15
;***************************************************************************
;** DialogControlState(dialog-handle,  control-number, request-code, style)
;***************************************************************************
DCSTATE_NULL         = 0    ; Dummy.
DCSTATE_SET_FOCUS      = 1    ; Give a control the input focus.
DCSTATE_QUERY_STYLE   = 2    ; Query a control's style.
DCSTATE_ADD_STYLE      = 3    ; Add one or more styles to a control.
DCSTATE_REMOVE_STYLE   = 4    ; Remove styles from a control.
DCSTATE_GET_FOCUS      = 5    ; Get control that has focus
;***************************************************************************
;** Style
;***************************************************************************
DCSTYLE_INVISIBLE      = 1    ; Control is invisible.
DCSTYLE_DISABLED      = 2    ; Control has disabled appearance and does not accept any user input, if would otherwise accept input.
DCSTYLE_LISTONLY      = 4    ; Control will only accept values already in the drop down list portion of the control.
DCSTYLE_BLOCKINPUT   = 8    ; The controls text cannot be change by typing in new text when the control has the input focus.
                            ;   (Note: The user can still change the value in a SPINNER controls by using the up and down arrows.
DCSTYLE_ASTERISK      = 16   ; Displays all characters as an asterisk (*) as they are typed into the control.
DCSTYLE_DEFAULT      = 32   ; A button with this style is the default button when no push or picture button has the input focus.
DCSTYLE_DIGITS         = 64   ; Allows only digits to be entered into the edit type controls.
                            ;   Note: even with this set, it is still possible to paste non-digits into the edit control.
DCSTYLE_FLAT         = 128  ; Creates a button with a flat appearance.
;***************************************************************************


;; UDFXcopy(<source directory>, <target directory>)
;; Performs an Xcopy-like function to copy a directory recursively.
;; Copied from Article ID W14748 on techsupt.winbatch.com
;; File Created: 2001:03:19:14:12:22
;; Modified 12/17/02 - Adrian Hayes

#DefineFunction UDFXcopy(fromdir,todir)
    ;make sure we have a full path or a UNC
    fromtest=StrIndex(fromdir,":",0,@FWDSCAN) + (StrSub(fromdir,1,2)=="\\")
    totest=StrIndex(todir,":",0,@FWDSCAN) + (StrSub(todir,1,2)=="\\")
    DirChange(fromdir)
    ;clean up passed paramters just in case
    If StrSub(fromdir,StrLen(fromdir),1) != "\" Then fromdir=StrCat(fromdir,"\")
    If StrSub(todir,StrLen(todir),1) != "\" Then todir=StrCat(todir,"\")

    ;Make sure target directory exists
    If DirExist(todir)==@FALSE Then DirMake(todir)

    ;copy files in this directory
    FileCopy( StrCat(fromdir,"*.*") , StrCat(todir,"*.*") , 0)

    ;get list of subdirectories
    dirlist=DirItemize("*.*")
    count=ItemCount(dirlist,@TAB)
    ;Preocess each subdirectory
    For xx=1 To count
       thisdir=ItemExtract(xx,dirlist,@TAB)
       fulltodir=StrCat(todir,thisdir,"\")
       fullfromdir=StrCat(fromdir,thisdir,"\")
       UDFXcopy(fullfromdir,fulltodir)
    Next
    Return
#EndFunction


;; UDFDELTREE(<directory>)
;; Performs an Deltree-like function to delete a directory recursively.
;; Copied from Article ID W14748 on techsupt.winbatch.com
;; File Created: 2001:03:19:14:12:22
;; Last Updated: 2002:06:26:08:13:59

#DefineFunction UDFDELTREE(dir)
   ;Include hidden files
   IntControl(5,1,0,0,0)
   ;change to target directory
   DirChange(dir)
   topdir=DirGet()
   ;Delete all files in target
   FileAttrSet("*.*","rash")
   FileDelete("*.*")
   ;Get list of subdirectories
   dirlist=DirItemize("*.*")
   ;Process list
   dircount=ItemCount(dirlist,@TAB)
   For xx=1 To dircount
      thisdir=ItemExtract(xx,dirlist,@TAB)
      UDFDELTREE(thisdir)
   Next
   ;bump up one directory level
   DirChange("..")
   ;remove that directory
   DirAttrSet(dir,"rash")
   DirRemove(dir)
   Return
#EndFunction




;***************************************************************************
;** Read Ini File
;***************************************************************************

If !FileExist(SetupIni)
   Message("Error:  Missing Setup.INI", StrCat("Setup.exe could not find the Setup.INI file in the folder", @CRLF, SetupHomeDir))
   Exit
EndIf

NumSteps = 0

TargetFolder = IniReadPvt("Folders", "TargetFolder", "", SetupIni)

;; Shortcut Folders
DefaultProgManGroup = IniReadPvt("ShortCut", "DefaultProgManGroup", "", SetupIni)
ShortCutName = IniReadPvt("ShortCut", "ShortCutName", "", SetupIni)
IconFile = IniReadPvt("ShortCut", "IconFile", "", SetupIni)

;; Installation info
InstallBMP = IniReadPvt("Install", "InstallBMP", "", SetupIni)
ProgName = IniReadPvt("Install", "ProgName", "", SetupIni)
ProgExeFile = IniReadPvt("Install", "ProgExeFile", "", SetupIni)
SourceFile = IniReadPvt("Install", "SourceFile", "", SetupIni)
SourceFile = StrCat(SetupHomeDir, SourceFile)
Copyright = IniReadPvt("Install", "Copyright", "", SetupIni)
ProgVer = IniReadPvt("Install", "ProgVer", "", SetupIni)
Contact = IniReadPvt("Install", "Contact", "", SetupIni)

;; Files copied to Program Folder
;; Required files listed in Ini file in this format:
;; filename.ext="Displayed Name"
;; e.g.,  Program.exe="Program Executable File"
Files = IniItemizePvt("Files", SetupIni)
If Files == "(NONE)" Then Files == ""
FileNames = ""
For CurFileNum = 1 To ItemCount(Files, @TAB)
   CurFileName = IniReadPvt("Files", ItemExtract(CurFileNum, Files, @TAB), "", SetupIni)
   FileNames = ItemInsert(CurFileName, -1, FileNames,@TAB)
Next CurFileNum

;; Files copied to Windows System folder
SysFiles = IniItemizePvt("SysFiles", SetupIni)
If SysFiles == "(NONE)" Then SysFiles = ""
SysFileNames = ""
For CurSysFileNum = 1 To ItemCount(SysFiles, @TAB)
   CurSysFileName = IniReadPvt("SysFiles", ItemExtract(CurSysFileNum, SysFiles, @TAB), "", SetupIni)
   SysFileNames = ItemInsert(CurSysFileName, -1, SysFileNames, @TAB)
Next SysFileNames




;***************************************************************************
;** Get Windows Version
;***************************************************************************
WinVer = WinVersion(4)
Switch WinVer
   Case 4            ;Windows NT/2000/XP
      Win9x = @FALSE
      Break
   Case 5            ;Windows 95/98/ME
      Win9x = @TRUE
      Break
   Case WinVer
      Message("OS Not Supported", StrCat(ProgName, "requires at least Windows 95 to run correctly."))
      Exit
EndSwitch



;***************************************************************************
;** Find Windows Shortcut Locations
;***************************************************************************
AppDataDir = ShortCutDir("AppData", 0, @TRUE)
QuickLaunchDir = StrCat(appdatadir,"Microsoft\Internet Explorer\Quick Launch\")
CommonAppDataDir = ShortCutDir("Common AppData", 1, @TRUE)
CommonQuickLaunchDir = StrCat(CommonAppDataDir, "Microsoft\Internet Explorer\Quick Launch\")
CommonStartMenuDir = ShortCutDir("Common Start Menu", 1, @TRUE)
StartMenuDir = ShortCutDir("Start Menu", 0, @TRUE)
ProgramsDir = StrCat(StartMenuDir, "Programs\")
StartupDir = ShortCutDir("Startup", 0, @TRUE)
DesktopDir = ShortCutDir("Common Desktop", 1, @TRUE)
SystemDir = DirWindows(1)

ShortcutsAlreadySet = @FALSE


;***************************************************************************
;** Welcome Dialog
;***************************************************************************
WelcomeFormat=`WWWDLGED,6.1`

WelcomeCaption=`Welcome`
WelcomeX=-01
WelcomeY=-01
WelcomeWidth=216
WelcomeHeight=169
WelcomeNumControls=015
WelcomeProcedure=`Welcome`
WelcomeFont=`DEFAULT`
WelcomeTextColor=`DEFAULT`
WelcomeBackground=`DEFAULT,DEFAULT`
WelcomeConfig=0

Welcome001=`163,147,036,012,PUSHBUTTON,DEFAULT,"Next &>",1,3,32,DEFAULT,DEFAULT,DEFAULT`
Welcome002=`007,147,036,012,PUSHBUTTON,DEFAULT,"Cancel",99,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Welcome003=`009,007,196,020,VARYTEXT,ProgName,DEFAULT,DEFAULT,7,DEFAULT,"Microsoft Sans Serif|12288|70|34","0|0|0",DEFAULT`
Welcome004=`013,061,036,036,PICTURE,DEFAULT,DEFAULT,DEFAULT,6,DEFAULT,DEFAULT,DEFAULT,%InstallBMP%`
Welcome005=`053,061,152,036,STATICTEXT,DEFAULT,"If you would like to continue, please click Next >.%@CRLF%%@CRLF%Please close open programs before continuing.",DEFAULT,5,DEFAULT,"Microsoft Sans Serif|6656|40|34","0|0|0",DEFAULT`
Welcome006=`011,039,194,016,STATICTEXT,DEFAULT,"This program will install %ProgName%",DEFAULT,2,DEFAULT,"Microsoft Sans Serif|8192|70|34","0|0|0",DEFAULT`
Welcome007=`059,103,094,008,VARYTEXT,ProgName,DEFAULT,DEFAULT,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Welcome008=`013,103,040,008,STATICTEXT,DEFAULT,"Program Name:",DEFAULT,8,1024,DEFAULT,DEFAULT,DEFAULT`
Welcome009=`013,111,040,008,STATICTEXT,DEFAULT,"Copyright:",DEFAULT,9,1024,DEFAULT,DEFAULT,DEFAULT`
Welcome010=`059,111,094,008,VARYTEXT,Copyright,DEFAULT,DEFAULT,10,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Welcome011=`013,119,040,008,STATICTEXT,DEFAULT,"Version:",DEFAULT,11,1024,DEFAULT,DEFAULT,DEFAULT`
Welcome012=`059,119,094,008,VARYTEXT,ProgVer,DEFAULT,DEFAULT,12,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Welcome013=`013,127,040,008,STATICTEXT,DEFAULT,"Contact:",DEFAULT,13,1024,DEFAULT,DEFAULT,DEFAULT`
Welcome014=`059,127,094,008,VARYTEXT,Contact,DEFAULT,DEFAULT,14,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Welcome015=`011,027,052,012,STATICTEXT,DEFAULT,"Welcome!",DEFAULT,15,DEFAULT,"Microsoft Sans Serif|8192|70|34","0|0|0",DEFAULT`




;***************************************************************************
;** Select Target Install location dialog
;***************************************************************************
#DefineSubRoutine Target(TargetHandle, EventCode, ControlNum, res4, res5)
If IsDefined(DebugMode)
   If DebugMode Then DebugTrace(DebugMode, Tempfile)
EndIf

Switch EventCode
   Case cDialogINIT
      DialogProcOptions(TargetHandle, cDialogBUTTON, @ON)
      DialogProcOptions(TargetHandle, cDialogEDITMULTIBOX, @ON)

      While @TRUE
         If AppExist(ProgExeFile, @FALSE)
            Pause("%ProgName% is Running", "Please close %ProgName% before continuing the installation.%@CRLF%%@CRLF%Press OK when ready or Cancel to quit")
         Else
            Break
         EndIf
      EndWhile

      SoftwareKey = RegOpenKey(@REGMACHINE, "SOFTWARE\")
      If RegExistKey(SoftwareKey, ProgName)
         Key = RegOpenKey(SoftwareKey, ProgName)
         If RegExistValue(Key, "[TargetFolder]")
            DialogControlSet(TargetHandle, 8, DCSET_REPLACE_TEXT, RegQueryValue(Key, "[TargetFolder]"))
         EndIf
         RegCloseKey(Key)
      EndIf
      RegCloseKey(SoftwareKey)

      Break

   Case cDialogBUTTON

      CurPath = DialogControlGet(TargetHandle, 8, DCGET_TEXT)
      If StrSub(CurPath, StrLen(CurPath), 1) != "\"
         CurPath = StrCat(CurPath, "\")
         DialogControlSet(TargetHandle, 8, DCSET_REPLACE_TEXT, CurPath)
      EndIf

      Switch ControlNum
         Case 1   ; Next

            If !DirExist(CurPath)
               LastError()
               ErrorMode(@OFF)
               TestMake = DirMake(CurPath)
               TestDel = DirRemove(CurPath)
               ErrorMode(@CANCEL)
               ErrorNum = LastError()
               If !TestMake || !TestDel || ErrorNum
                  ErrMsg = "Setup could not create the specified folder.%@CRLF%Please choose another path.%@CRLF%%@CRLF%This could have occured because:"
                  ErrMsg = StrCat(ErrMsg, "%@CRLF%%@TAB%- The drive does not exist.%@CRLF%%@TAB%- You do not have full rights to the target path.%@CRLF%%@TAB%- The target is read-only.")
                  Message("Failed to Create Folder", ErrMsg)
                  Return -2
               EndIf
            EndIf


            Return 1

         Case 2   ; Back
            Return 2

         Case 3   ; Cancel
            Return 99

         Case 9   ; Browse
            Flags = 1|4
            BrowsePreExist = @TRUE
            If !DirExist(CurPath)
               BrowsePreExist = @FALSE
               ErrorMode(@OFF)
               DirMake(CurPath)
               ErrorMode(@CANCEL)
            EndIf
            BrowsePath = AskDirectory("Please select a target folder:", "", CurPath, "", Flags)
            If !BrowsePreExist
               ErrorMode(@OFF)
               DirRemove(CurPath)
               ErrorMode(@CANCEL)
            EndIf

            DialogControlSet(TargetHandle, 8, DCSET_REPLACE_TEXT, BrowsePath)
            Break

      EndSwitch
      Break


   Case cDialogEDITMULTIBOX

      CurPath = DialogControlGet(TargetHandle, 8, DCGET_TEXT)
      OffendingCharPos = StrScan(CurPath, "/*?""<>|", 1, @FWDSCAN)
      If OffendingCharPos
         Message("Invalid Character", "The path cannot contain the following characters: / * ? "" < > |")
         CurPath = StrSub(CurPath, 1, OffendingCharPos - 1)
         DialogControlSet(TargetHandle, 8, DCSET_REPLACE_TEXT, CurPath)
      EndIf
      Break

EndSwitch
Return -2

#EndSubRoutine
TargetFormat=`WWWDLGED,6.1`

TargetCaption=`Select Installation Target`
TargetX=-01
TargetY=-01
TargetWidth=216
TargetHeight=169
TargetNumControls=009
TargetProcedure=`Target`
TargetFont=`DEFAULT`
TargetTextColor=`DEFAULT`
TargetBackground=`DEFAULT,DEFAULT`
TargetConfig=0

Target001=`163,147,036,012,PUSHBUTTON,DEFAULT,"Next &>",1,3,32,DEFAULT,DEFAULT,DEFAULT`
Target002=`121,147,036,012,PUSHBUTTON,DEFAULT,"&< Back",2,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Target003=`007,147,036,012,PUSHBUTTON,DEFAULT,"Cancel",99,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Target004=`009,007,196,020,VARYTEXT,ProgName,DEFAULT,DEFAULT,7,DEFAULT,"Microsoft Sans Serif|12288|70|34","0|0|0",DEFAULT`
Target005=`011,055,036,036,PICTURE,DEFAULT,DEFAULT,DEFAULT,6,DEFAULT,DEFAULT,DEFAULT,%InstallBMP%`
Target006=`007,027,200,016,GROUPBOX,DEFAULT,DEFAULT,DEFAULT,8,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Target007=`009,031,196,016,STATICTEXT,DEFAULT,"Where would you like to install the program?",DEFAULT,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Target008=`055,061,148,012,EDITBOX,TargetFolder,DEFAULT,DEFAULT,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Target009=`167,075,036,012,PUSHBUTTON,DEFAULT,"&Browse",3,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`



;***************************************************************************
;** Shortcut location dialog
;***************************************************************************
#DefineSubRoutine Shortcut(ShortcutHandle, EventCode, ControlNum, res4, res5)
If IsDefined(DebugMode)
   If DebugMode Then DebugTrace(DebugMode, Tempfile)
EndIf

Switch EventCode
   Case cDialogINIT
      DialogProcOptions(ShortcutHandle, cDialogBUTTON, @ON)

      SoftwareKey = RegOpenKey(@REGMACHINE, "SOFTWARE\")
      If RegExistKey(SoftwareKey, ProgName)
         Key = RegOpenKey(SoftwareKey, ProgName)
         If RegExistValue(Key, "[DesktopIcon]")
            DialogControlSet(ShortcutHandle, 9, DCSET_VALUE, RegQueryValue(Key, "[DesktopIcon]"))
         EndIf
         If RegExistValue(Key, "[StartMenuIcon]")
            DialogControlSet(ShortcutHandle, 10, DCSET_VALUE, RegQueryValue(Key, "[StartMenuIcon]"))
         EndIf
         If RegExistValue(Key, "[QuickLaunchIcon]")
            DialogControlSet(ShortcutHandle, 11, DCSET_VALUE, RegQueryValue(Key, "[QuickLaunchIcon]"))
         EndIf
         If RegExistValue(Key, "[StartupIcon]")
            DialogControlSet(ShortcutHandle, 12, DCSET_VALUE, RegQueryValue(Key, "[StartupIcon]"))
         EndIf
         RegCloseKey(Key)
      Else
         If !ShortcutsAlreadySet
            DialogControlSet(ShortcutHandle, 9, DCSET_VALUE, @ON)
            DialogControlSet(ShortcutHandle, 10, DCSET_VALUE, @ON)
            DialogControlSet(ShortcutHandle, 11, DCSET_VALUE, @ON)
            DialogControlSet(ShortcutHandle, 12, DCSET_VALUE, @OFF)
         EndIf
      EndIf

      RegCloseKey(SoftwareKey)

      If !DirExist(QuickLaunchDir)            ;; Determine if the QuickLaunch folder is available - doesn't exist pre-IE4
         If !DirExist(CommonQuickLaunchDir)
            DialogControlSet(ShortcutHandle, 11, DCSET_VALUE, @OFF)
            DialogControlState(ShortcutHandle, 11, DCSTATE_ADD_STYLE. DCSTYLE_DISABLED
         EndIf
      EndIf
      Break

   Case cDialogBUTTON
      ShortcutsAlreadySet = @TRUE
      Switch ControlNum

         Case 1   ; Next

            Return 1

         Case 2   ; Back
            Return 2

         Case 3   ; Cancel
            Return 99

      EndSwitch
      Break

EndSwitch
Return -2

#EndSubRoutine

ShortCutFormat=`WWWDLGED,6.1`

ShortCutCaption=`Select Shortcut Locations`
ShortCutX=-1
ShortCutY=-1
ShortCutWidth=216
ShortCutHeight=169
ShortCutNumControls=012
ShortCutProcedure=`ShortCut`
ShortCutFont=`DEFAULT`
ShortCutTextColor=`DEFAULT`
ShortCutBackground=`DEFAULT,DEFAULT`
ShortCutConfig=0

ShortCut001=`163,147,036,012,PUSHBUTTON,DEFAULT,"Next &>",1,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ShortCut002=`121,147,036,012,PUSHBUTTON,DEFAULT,"&< Back",2,6,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ShortCut003=`007,147,036,012,PUSHBUTTON,DEFAULT,"Cancel",99,7,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ShortCut004=`009,007,196,020,VARYTEXT,ProgName,DEFAULT,DEFAULT,99,DEFAULT,"Microsoft Sans Serif|12288|70|34","0|0|0",DEFAULT`
ShortCut005=`011,055,036,036,PICTURE,DEFAULT,DEFAULT,DEFAULT,99,DEFAULT,DEFAULT,DEFAULT,"%InstallBMP%"`
ShortCut006=`009,031,196,016,STATICTEXT,DEFAULT,"Where would you like to place the shortcut?",DEFAULT,99,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ShortCut007=`007,027,200,016,GROUPBOX,DEFAULT,DEFAULT,DEFAULT,8,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ShortCut008=`057,051,146,066,GROUPBOX,DEFAULT,DEFAULT,DEFAULT,99,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ShortCut009=`069,065,044,012,CHECKBOX,DesktopIcon,"&Desktop",1,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ShortCut010=`069,079,044,012,CHECKBOX,StartMenuIcon,"&Start Menu",1,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ShortCut011=`069,093,078,012,CHECKBOX,QuickLaunchIcon,"&Quick Launch Toolbar",1,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ShortCut012=`057,117,144,012,CHECKBOX,StartupIcon,"&Run every time Windows starts",2,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT`



;***************************************************************************
;** Start Menu Program Group dialog
;***************************************************************************
#DefineSubRoutine ProgGroup(ProgGroupHandle, EventCode, ControlNum, res4, res5)
If IsDefined(DebugMode)
   If DebugMode Then DebugTrace(DebugMode, Tempfile)
EndIf

Switch EventCode
   Case cDialogINIT

      DialogProcOptions(ProgGroupHandle, cDialogBUTTON, @ON)
      DialogProcOptions(ProgGroupHandle, cDialogEDITMULTIBOX, @ON)
      DialogProcOptions(ProgGroupHandle, cDialogITEMBOX, @ON)

      UserProgGroups = DirItemize(StrCat(StartMenuDir, "Programs\*.*"))
      CommonProgGroups = DirItemize(StrCat(CommonStartMenuDir, "Programs\*.*"))

      PMGroupsNonDup = CommonProgGroups

      For CurPMGroupNum = 1 To ItemCount(UserProgGroups, @TAB)
         CurPMGroup = ItemExtract(CurPMGroupNum, UserProgGroups, @TAB)
         If !ItemLocate(CurPMGroup, PMGroupsNonDup, @TAB)
            PMGroupsNonDup = ItemInsert(CurPMGroup, -1, PMGroupsNonDup, @TAB)
         EndIf
      Next CurPMGroupNum
      PMGroups = ItemSort(PMGroupsNonDup, @TAB)

      DialogControlSet(ProgGroupHandle, 8, DCSET_REPLACE_LIST, PMGroups)

      Break

   Case cDialogBUTTON
      PMGroupTyped = DialogControlGet(ProgGroupHandle, 9, DCGET_TEXT)
      Switch ControlNum
         Case 1   ; Next
            If PMGroupTyped != ""
               Return 1
            Else
               Message("Program Group Not Selected", "Please select a program group.")
               Break
            EndIf

         Case 2   ; Back
            Return 2

         Case 3
            Return 99
      EndSwitch
      Break


   Case cDialogEDITMULTIBOX
      PMGroupTyped = DialogControlGet(ProgGroupHandle, 9, DCGET_TEXT)

      OffendingCharPos = StrScan(PMGroupTyped, "/*?""<>|", 1, @FWDSCAN)
      If OffendingCharPos
         Message("Invalid Character", "The program group cannot contain the following characters: / * ? "" < > |")
         PMGroupTyped = StrSub(PMGroupTyped, 1, OffendingCharPos - 1)
         DialogControlSet(TargetHandle, 8, DCSET_REPLACE_TEXT, PMGroupTyped)
      EndIf

      If ItemLocate(PMGroupTyped, PMGroups, @TAB)
         DialogControlSet(ProgGroupHandle, 8, DCSET_ITEM_SELECTED, PMGroupTyped)
      Else
         DialogControlSet(ProgGroupHandle, 8, DCSET_ITEM_SELECTED, "")
      EndIf
      Break

   Case cDialogITEMBOX
      PMGroupSelected = DialogControlGet(ProgGroupHandle, 8, DCGET_ITEM)
      DialogControlSet(ProgGroupHandle, 9, DCSET_REPLACE_TEXT, PMGroupSelected)
      Break

EndSwitch
Return -2

#EndSubRoutine

ProgGroupFormat=`WWWDLGED,6.1`

ProgGroupCaption=`Select Program Manager Group`
ProgGroupX=-01
ProgGroupY=-01
ProgGroupWidth=220
ProgGroupHeight=169
ProgGroupNumControls=009
ProgGroupProcedure=`ProgGroup`
ProgGroupFont=`DEFAULT`
ProgGroupTextColor=`DEFAULT`
ProgGroupBackground=`DEFAULT,DEFAULT`
ProgGroupConfig=0

ProgGroup001=`163,147,036,012,PUSHBUTTON,DEFAULT,"Next &>",1,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ProgGroup002=`121,147,036,012,PUSHBUTTON,DEFAULT,"&< Back",2,4,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ProgGroup003=`007,147,036,012,PUSHBUTTON,DEFAULT,"Cancel",99,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ProgGroup004=`009,007,196,020,VARYTEXT,ProgName,DEFAULT,DEFAULT,9,DEFAULT,"Microsoft Sans Serif|12288|70|34","0|0|0",DEFAULT`
ProgGroup005=`011,051,036,036,PICTURE,DEFAULT,DEFAULT,DEFAULT,99,DEFAULT,DEFAULT,DEFAULT,%InstallBMP%`
ProgGroup006=`009,031,196,016,STATICTEXT,DEFAULT,"Enter the Start menu Program Manager Group for the icon:",DEFAULT,99,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ProgGroup007=`007,027,200,016,GROUPBOX,DEFAULT,DEFAULT,DEFAULT,8,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ProgGroup008=`073,063,134,072,ITEMBOX,PMGroups,DEFAULT,DEFAULT,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
ProgGroup009=`073,049,134,012,EDITBOX,PMGroupSelected,"%DefaultProgManGroup%",DEFAULT,1,DEFAULT,DEFAULT,DEFAULT,DEFAULT`



;***************************************************************************
;** Confirm Settings dialog
;***************************************************************************

#DefineSubRoutine Confirm(ConfirmHandle, EventCode, ControlNum, res4, res5)
If IsDefined(DebugMode)
   If DebugMode Then DebugTrace(DebugMode, Tempfile)
EndIf

Switch EventCode

   Case cDialogINIT
      ConfirmDetails = StrCat("Installing ", ProgName, @CRLF, @CRLF)
      ConfirmDetails = StrCat(ConfirmDetails, "Target Folder:  ", TargetFolder, @CRLF, @CRLF)

      ConfirmDetails = StrCat(ConfirmDetails, "Shortcuts Requested:  ", @CRLF)
      If DesktopIcon Then ConfirmDetails = StrCat(ConfirmDetails, "    - Desktop Shortcut", @CRLF)

      If StartMenuIcon
         ConfirmDetails = StrCat(ConfirmDetails, "    - Start Menu Shortcut", @CRLF)
         ConfirmDetails = StrCat(ConfirmDetails, "         Program Group: ", PMGroupSelected, @CRLF)
      EndIf

      If QuickLaunchIcon Then ConfirmDetails = StrCat(ConfirmDetails, "    - Quick Launch Shortcut", @CRLF)
      ConfirmDetails = StrCat(ConfirmDetails, @CRLF)

      If StartupIcon Then ConfirmDetails = StrCat(ConfirmDetails, "Starting every time Windows loads", @CRLF, @CRLF)

      DialogControlSet(ConfirmHandle, 8, DCSET_REPLACE_TEXT, ConfirmDetails)

      Break

EndSwitch

Return -2
#EndSubRoutine
ConfirmFormat=`WWWDLGED,6.1`

ConfirmCaption=`Ready to Install`
ConfirmX=-01
ConfirmY=-01
ConfirmWidth=220
ConfirmHeight=169
ConfirmNumControls=008
ConfirmProcedure=`Confirm`
ConfirmFont=`DEFAULT`
ConfirmTextColor=`DEFAULT`
ConfirmBackground=`DEFAULT,DEFAULT`
ConfirmConfig=0

Confirm001=`163,147,036,012,PUSHBUTTON,DEFAULT,"Next &>",1,1,32,DEFAULT,DEFAULT,DEFAULT`
Confirm002=`123,147,036,012,PUSHBUTTON,DEFAULT,"&< Back",2,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Confirm003=`007,147,036,012,PUSHBUTTON,DEFAULT,"Cancel",99,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Confirm004=`009,007,196,020,VARYTEXT,ProgName,DEFAULT,DEFAULT,9,DEFAULT,"Microsoft Sans Serif|12288|70|34","0|0|0",DEFAULT`
Confirm005=`011,051,036,036,PICTURE,DEFAULT,DEFAULT,DEFAULT,99,DEFAULT,DEFAULT,DEFAULT,%InstallBMP%`
Confirm006=`009,031,196,016,STATICTEXT,DEFAULT,"Press Next to complete the Installation",DEFAULT,99,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Confirm007=`007,027,200,016,GROUPBOX,DEFAULT,DEFAULT,DEFAULT,8,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Confirm008=`065,051,142,082,MULTILINEBOX,ConfirmDetails,DEFAULT,DEFAULT,7,8,DEFAULT,DEFAULT,DEFAULT`


;***************************************************************************
;** Status of Installation dialog
;***************************************************************************
#DefineSubRoutine Status(StatusHandle, EventCode, ControlNum, res4, res5)
If IsDefined(DebugMode)
   If DebugMode Then DebugTrace(DebugMode, Tempfile)
EndIf

Switch EventCode
   Case cDialogINIT
      DialogProcOptions(StatusHandle, cDialogTIMER, 100)
      DialogProcOptions(StatusHandle, cDialogBUTTON, @ON)

      NumSteps = NumSteps + ItemCount(Files, @TAB) + ItemCount(SysFiles, @TAB) + 6

      ;********************************************************
      ;** Create Progress bar
      ;********************************************************
      PpHDU = (WinMetrics(-6))   ; Used for Dialog draws - Pixels per Horiz. Dialog Unit
      PpVDU = (WinMetrics(-5))   ; Used for Dialog draws - Pixels per Vertical Dialog Unit
      htree=BarCreate(Int(65 * PpHDU),Int(57 * PpVDU),Int(142 * PpHDU),Int(12 * PpVDU),PBS_SMOOTH,StatusHandle)
      BarSetRange(htree,0,NumSteps)
      BarSetStep(htree,1)
      BarSetBarColour(htree,SetColour(0,200,0))
      BarStepIt(htree)


      ;********************************************************
      ;**  Make a backup copy of existing target
      ;********************************************************
      If DirExist(TargetFolder)
         If FileItemize(StrCat(TargetFolder, "*.*")) != ""
            TempFolder = FileCreateTemp("Old")
            FileDelete(TempFolder)
            DirMake(TempFolder)
            TempFolder = StrCat(TempFolder, "\")
            UDFXcopy(TargetFolder, StrCat(TempFolder, "Old\"))
            UDFDELTREE(TargetFolder)
         EndIf
      EndIf

      If !IsDefined(TempFolder)
            TempFolder = FileCreateTemp("Old")
            FileDelete(TempFolder)
            DirMake(TempFolder)
            TempFolder = StrCat(TempFolder, "\")
      EndIf

      DirMake(TargetFolder)

      StepNum = 1

      DoFiles = @TRUE
      DoSysFiles = @FALSE
      DoShortCuts = @FALSE
      DoRegEntries = @FALSE

      Break

   Case cDialogTIMER
      If DoFiles
         If StepNum <= ItemCount(Files, @TAB)

            BarStepIt(htree)

            CurFile = ItemExtract(StepNum, Files, @TAB)
            CurFileName = ItemExtract(StepNum, FileNames, @TAB)
            DialogControlSet(StatusHandle, 8, DCSET_REPLACE_TITLE, StrCat("File:  ", CurFile))
            DialogControlSet(StatusHandle, 7, DCSET_REPLACE_TITLE, StrCat("Installing:  ", CurFileName))


            ErrorCode = zUnZipFiles("", SourceFile, CurFile, "", TargetFolder)
         Else
            StepNum = 1
            DoFiles = @FALSE
            DoSysFiles = @TRUE
         EndIf
      EndIf


      If DoSysFiles
         If StepNum <= ItemCount(SysFiles, @TAB)

            BarStepIt(htree)

            CurSysFile = ItemExtract(StepNum, SysFiles, @TAB)
            CurSysFileName = ItemExtract(StepNum, SysFileNames, @TAB)
            DialogControlSet(StatusHandle, 8, DCSET_REPLACE_TITLE, StrCat("File:  ", CurSysFile))
            DialogControlSet(StatusHandle, 7, DCSET_REPLACE_TITLE, StrCat("Installing:  (System):", CurSysFileName))

            ErrorCode = zUnZipFiles("", SourceFile, CurSysFile, "", SystemDir)
         Else
            StepNum = 1
            DoSysFiles = @FALSE
            DoShortcuts = @TRUE
            DoRegEntries = @FALSE
         EndIf
      EndIf

      If DoShortcuts
         DialogControlSet(StatusHandle, 8, DCSET_REPLACE_TITLE, "")

         BarStepIt(htree)
         If DesktopIcon
            DialogControlSet(StatusHandle, 7, DCSET_REPLACE_TITLE, "Creating Desktop Shortcut")
            If FileExist(StrCat(DesktopDir, "\", ShortcutName)) Then FileDelete(StrCat(DesktopDir, "\", ShortcutName))
            ShortCutMake(StrCat(DesktopDir, "\", ShortcutName), StrCat(TargetFolder, ProgExeFile), "", TargetFolder, @NORMAL, 0)
            TimeDelay(.5)
         EndIf
         BarStepIt(htree)
         If StartMenuIcon
            DialogControlSet(StatusHandle, 7, DCSET_REPLACE_TITLE, "Creating Start Menu Shortcut")
            PMGroupFolder = StrCat(CommonStartMenuDir, "Programs\", PMGroupSelected)
            DirMake(PMGroupFolder)
            If FileExist(StrCat(PMGroupFolder, "\", ShortcutName)) Then FileDelete(StrCat(PMGroupFolder, "\", ShortcutName))
            ShortCutMake(StrCat(PMGroupFolder, "\", ShortcutName), StrCat(TargetFolder, ProgExeFile), "", TargetFolder, @NORMAL, 0)
            TimeDelay(.5)
         EndIf
         BarStepIt(htree)
         If QuickLaunchIcon
            DialogControlSet(StatusHandle, 7, DCSET_REPLACE_TITLE, "Creating QuickLaunch Shortcut")
            If DirExist(QuickLaunchDir)
               If FileExist(StrCat(QuickLaunchDir, ShortcutName)) Then FileDelete(StrCat(QuickLaunchDir, ShortcutName))
               ShortCutMake(StrCat(QuickLaunchDir, ShortcutName), StrCat(TargetFolder, ProgExeFile), "", TargetFolder, @NORMAL, 0)
            Else
               If FileExist(StrCat(CommonQuickLaunchDir, ShortcutName)) Then FileDelete(StrCat(CommonQuickLaunchDir, ShortcutName))
               ShortCutMake(StrCat(CommonQuickLaunchDir, ShortcutName), StrCat(TargetFolder, ProgExeFile), "", TargetFolder, @NORMAL, 0)
            EndIf
            TimeDelay(.5)
         EndIf
         BarStepIt(htree)
         If StartupIcon
            DialogControlSet(StatusHandle, 7, DCSET_REPLACE_TITLE, "Creating Startup Shortcut")
            If FileExist(StrCat(StartupDir, "\", ShortcutName)) Then FileDelete(StrCat(StartupDir, "\", ShortcutName))
            ShortCutMake(StrCat(StartupDir, "\", ShortcutName), StrCat(TargetFolder, ProgExeFile), "", TargetFolder, @NORMAL, 0)
            TimeDelay(.5)
         Else
            If FileExist(StrCat(StartupDir, "\", ShortcutName)) Then FileDelete(StrCat(StartupDir, "\", ShortcutName))
         EndIf

         DoShortCuts = @FALSE
         DoRegEntries = @TRUE
      EndIf

      If DoRegEntries

            BarStepIt(htree)

            DialogProcOptions(StatusHandle, cDialogTimer, @OFF)
            DialogControlSet(StatusHandle, 8, DCSET_REPLACE_TITLE, "")
            DialogControlSet(StatusHandle, 7, DCSET_REPLACE_TITLE, "Registering Program")

            RegApp(StrCat(TargetFolder, ProgExeFile), TargetFolder)

            SoftwareKey = RegOpenKey(@REGMACHINE, "SOFTWARE\")
            Key = RegCreateKey(SoftwareKey, ProgName)
            RegSetValue(Key, "[TargetFolder]", TargetFolder)
            RegSetValue(Key, "[DesktopIcon]", DesktopIcon)
            RegSetValue(Key, "[StartMenuIcon]", StartMenuIcon)
            RegSetValue(Key, "[QuickLaunchIcon]", QuickLaunchIcon)
            RegSetValue(Key, "[StartupIcon]", StartupIcon)

            RegCloseKey(SoftwareKey)
            RegCloseKey(Key)

            TimeDelay(1)
            DialogControlSet(StatusHandle, 7, DCSET_REPLACE_TITLE, "Finished!")
            DialogControlState(StatusHandle, 1, DCSTATE_REMOVE_STYLE, DCSTYLE_DISABLED)
      EndIf

      StepNum = StepNum + 1

      Break


   Case cDialogBUTTON

      Switch ControlNum

         Case 1   ;; Done

            Return 1
            Break

         Case 2   ;; Cancel
         ButtonPushed=Dialog("ConfirmQuit")
         If ButtonPushed == 1
            DoLoop = @FALSE
            Failure = @TRUE
            Return 1
         EndIf
         Break

      EndSwitch
      Break

EndSwitch
Return -2

#EndSubRoutine

StatusFormat=`WWWDLGED,6.1`

StatusCaption=`Installation Status`
StatusX=-01
StatusY=-01
StatusWidth=220
StatusHeight=169
StatusNumControls=009
StatusProcedure=`Status`
StatusFont=`DEFAULT`
StatusTextColor=`DEFAULT`
StatusBackground=`DEFAULT,DEFAULT`
StatusConfig=0

Status001=`163,147,036,012,PUSHBUTTON,DEFAULT,"&Done",1,3,2,DEFAULT,DEFAULT,DEFAULT`
Status002=`007,147,036,012,PUSHBUTTON,DEFAULT,"Cancel",99,5,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Status003=`009,007,196,020,VARYTEXT,ProgName,DEFAULT,DEFAULT,9,DEFAULT,"Microsoft Sans Serif|12288|70|34","0|0|0",DEFAULT`
Status004=`011,051,036,036,PICTURE,DEFAULT,DEFAULT,DEFAULT,99,DEFAULT,DEFAULT,DEFAULT,%InstallBMP%`
Status005=`009,031,196,016,STATICTEXT,DEFAULT,"Installation Status",DEFAULT,99,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Status006=`007,027,200,016,GROUPBOX,DEFAULT,DEFAULT,DEFAULT,8,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Status007=`065,083,142,012,STATICTEXT,DEFAULT,"Installing:",DEFAULT,6,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Status008=`145,071,062,012,STATICTEXT,DEFAULT,"File:",DEFAULT,10,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
Status009=`065,113,144,012,CHECKBOX,StartProgWhenDone,"Start %ProgName% when finished?",1,7,DEFAULT,DEFAULT,DEFAULT,DEFAULT`




ConfirmQuitFormat=`WWWDLGED,6.1`

ConfirmQuitCaption=`Confirm Exit`
ConfirmQuitX=-01
ConfirmQuitY=-01
ConfirmQuitWidth=152
ConfirmQuitHeight=059
ConfirmQuitNumControls=003
ConfirmQuitProcedure=`DEFAULT`
ConfirmQuitFont=`DEFAULT`
ConfirmQuitTextColor=`DEFAULT`
ConfirmQuitBackground=`DEFAULT,DEFAULT`
ConfirmQuitConfig=0

ConfirmQuit001=`007,040,036,012,PUSHBUTTON,DEFAULT,"&Yes",1,1,0,DEFAULT,DEFAULT,DEFAULT`
ConfirmQuit002=`105,040,036,012,PUSHBUTTON,DEFAULT,"&No",99,2,32,DEFAULT,DEFAULT,DEFAULT`
ConfirmQuit003=`007,007,134,032,STATICTEXT,DEFAULT,"The installation did not successfully complete.  Do you want to quit?",DEFAULT,3,512,"Microsoft Sans Serif|8192|40|34","0|0|0",DEFAULT`




;***************************************************************************
;** MAIN
;***************************************************************************

DialogNum = 1
Dialogs = "Welcome   Target   ShortCut   ProgGroup   Confirm   Status"
DoLoop = @TRUE
Failure = @FALSE


While DoLoop
   DialogNum = Max(1, DialogNum)

   If DialogNum > ItemCount(Dialogs, @TAB) Then Break

   CurDialog = ItemExtract(DialogNum, Dialogs, @TAB)

   If CurDialog == "ProgGroup"
      If IsDefined(StartMenuIcon)
         If !StartMenuIcon
            If ButtonPushed == 1
               DialogNum = DialogNum + 1
            Else
               DialogNum = DialogNum - 1
            EndIf
            Continue
         EndIf
      EndIf
   EndIf

   ButtonPushed=Dialog(CurDialog)

   Switch ButtonPushed
      Case 1   ; Next, Done, or Finish
         DialogNum = DialogNum + 1
         Break

      Case 2   ; Back
         DialogNum = DialogNum - 1
         Break

      Case 99   ; Cancel or End
         If DialogNum < ItemCount(Dialogs, @TAB) || Failure
            ButtonPushed=Dialog("ConfirmQuit")
            If ButtonPushed == 1
               DoLoop = @FALSE
               Failure = @TRUE
               Break
            EndIf
            Break
         Else
            Failure = @FALSE
            Break
         EndIf
   EndSwitch

EndWhile


If Failure
   If IsDefined(TempFolder)
      udfDELTREE(TargetFolder)
      DirMake(TargetFolder)
      UDFXcopy(StrCat(TempFolder, "Old\"), TargetFolder)
      udfDELTREE(TempFolder)
   EndIf
Else

   TimeDelay(1)
   If DirExist(TempFolder) Then udfDELTREE(TempFolder)

   If StartProgWhenDone
      Run(StrCat(TargetFolder, ProgExeFile), "")
   EndIf

EndIf


Setup.ini

[Install]
InstallBMP=".\progpicture.bmp"
ProgName="Program Name"
ProgExeFile="Program.exe"
SourceFile="Program.zip"
Copyright="2004, Program Designer"
ProgVer="Program version 1.0"
Contact="Program Programmer (programer@program.com)"

[Folders]
TargetFolder="C:\Program Files\Program\"

[Files]
Program.exe="Program File"
Program.bmp="Program Graphic"
Program.ini="Program Initiation File"
Program.ico="Program Icon"


[NonOverwriteFiles]

[ForceUpdateFiles]

[SysFiles]
wwctl34i.dll="Window Control Library"
wbdCH34i.dll="Script Processor Library"
wbdCI34i.dll="Dialog Control Interface Library"
wbdDA34i.dll="Script Processor DLL"
WBODA34I.DLL="Script Processor OLE Interface DLL"

[ForceUpdateSysFiles]

[RegEntries]

[ShortCut]
DefaultProgManGroup="Program"
ShortCutName="Program.lnk"
IconFile="Program.ico"

Article ID:   W17220
File Created: 2007:07:03:14:28:52
Last Updated: 2007:07:03:14:28:52