home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 2.00 Begin Form Setup1 BackColor = &H00400000& Caption = "Test App Setup" ControlBox = 0 'False FillStyle = 0 'Solid FontBold = -1 'True FontItalic = -1 'True FontName = "MS Sans Serif" FontSize = 24 FontStrikethru = 0 'False FontUnderline = 0 'False ForeColor = &H00000000& Height = 2535 Icon = SETUP1.FRX:0000 Left = 1800 LinkMode = 1 'Source LinkTopic = "Form3" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 142 ScaleMode = 3 'Pixel ScaleWidth = 376 Top = 2265 Width = 5760 Begin Label Label2 BorderStyle = 1 'Fixed Single Caption = "To customize this setup program, modify the FORM_LOAD event procedure in this form." Height = 435 Left = 15 TabIndex = 1 Top = 15 Visible = 0 'False Width = 5625 End Begin Label Label1 BorderStyle = 1 'Fixed Single Caption = "This label used for DDE connection to the Program Manager" Height = 390 Left = 15 TabIndex = 0 Top = 525 Visible = 0 'False Width = 5610 End Const APPNAME = "Loan Application" Const APPDIR = "C:\LOAN" ' The default install directory ' Set the total uncompressed file sizes ' by adding the sizes of the files Const WINSYSNEEDED = 40896 ' Files that go into WINDOWS and SYSTEM directory Const OTHERNEEDED = 12555 ' Files that don't go into the WINDOWS or SYSTEM directory Sub DrawBackground () Setup1.CurrentY = 5 Setup1.CurrentX = 5 Setup1.ForeColor = QBColor(15) Print APPNAME + " Setup" End Sub Sub Form_Load () '---------- ' Initialize '---------- dialogCaption$ = APPNAME + " Setup" ShowMainForm dialogCaption$ '---------------------------------------------------- ' SETUP.EXE passes the source drive in a command ' argument. If it is empty, that means the user ' executed this .exe directly. In that case, show ' a dialog to get the desired source directory. '---------------------------------------------------- SourcePath$ = Command$ If SourcePath$ = "" Then title$ = dialogCaption$ caption1$ = "Please enter the drive or path containing the " + APPNAME + " source files." caption2$ = "Install From:" defaultDrive$ = "A:" defaultText$ = "A:\" ShowPathDialog title$, caption1$, caption2$, defaultDrive$, defaultText$, SourcePath$, outButton$ If outButton$ = "exit" Then GoTo ErrorSetup Else If Right$(SourcePath$, 1) <> "\" Then SourcePath$ = SourcePath$ + "\" End If End If '-------------------- ' Get Destination Path '-------------------- title$ = dialogCaption$ caption1$ = "If you want to install the test application in a different directory and/or drive, type the name of the directory." caption2$ = "Install To:" defaultDrive$ = "C:" defaultText$ = APPDIR ShowPathDialog title$, caption1$, caption2$, defaultDrive$, defaultText$, destPath$, outButton$ If outButton$ = "exit" Then GoTo ErrorSetup '--------------------- ' Sample Option Dialog '--------------------- ' ReDim Caption(1 To 4) As String ' ReDim choice(1 To 4) As Integer ' title$ = dialogCaption$ ' numOptions = 4 ' Caption(1) = "Sample Option 1" ' Caption(2) = "Sample Option 2" ' Caption(3) = "Sample Option 3" ' Caption(4) = "Sample Option 4" ' helpTxt$ = "Choose your options! These options are not actually used by this setup program, but by looking in the SETUP1.FRM code you can see how to implement your own option dialogs." ' ShowOptionDialog title$, numOptions, Caption$(), helpTxt$, choice(), outButton$ ' If outButton$ = "exit" Then ' GoTo ErrorSetup ' Else ' If choice(1) Then MsgBox "Option #1 Selected", 48, "SETUP" ' If choice(2) Then MsgBox "Option #2 Selected", 48, "SETUP" ' If choice(3) Then MsgBox "Option #3 Selected", 48, "SETUP" ' If choice(4) Then MsgBox "Option #4 Selected", 48, "SETUP" ' End If '----------------------------------------- ' Dim disk space variables as Long Integers '----------------------------------------- Dim winSpaceFree As Long Dim sourceSpaceFree As Long Dim destSpaceFree As Long Dim totalNeeded As Long winDir$ = GetWindowsDir$() winSysDir$ = GetWindowsSysDir$() '--------------------------------------------------------- ' If the Windows \SYSTEM directory is a subdirectory ' of the Windows directory, the proper place for ' installation of .VBXs and shared .DLLs is the ' Windows \SYSTEM directory. ' ' If the Windows \SYSTEM directory is *not* a subdirectory ' of the Windows directory, then the user is running a ' shared version of Windows, and the proper place for ' installation of .VBXs and shared .DLLs is the ' Windows directory. '--------------------------------------------------------- If InStr(winSysDir$, winDir$) = 0 Then winSysDir$ = winDir$ End If '--------------------------------- ' Get Drive Letters of directories '--------------------------------- winDrive$ = UCase$(Left$(winDir$, 1)) destDrive$ = UCase$(Left$(destPath$, 1)) sourceDrive$ = UCase$(Left$(SourcePath$, 1)) '--------------------------------- ' Compute free disk space variables '--------------------------------- winSpaceFree = GetDiskSpaceFree(winDrive$) destSpaceFree = GetDiskSpaceFree(destDrive$) '----------------------------------------- ' Check for enough disk space. ' ' Some components are being installed into the ' Windows\SYSTEM directory. ' ' So if the main destination path is on a ' different drive than the drive with ' the Windows \SYSTEM directory, we have to ' check both drives. ' ' An example of this is when the user is installing ' the main product to drive D:, but the Windows ' directory is on drive c: ' ----------------------------------------- totalNeeded = WINSYSNEEDED + OTHERNEEDED If winDrive$ = destDrive$ Then If destSpaceFree < totalNeeded Then MsgBox "There is not enough disk space on drive " + destDrive$ + ": An estimated" + Str$(totalNeeded - destSpaceFree) + " additional bytes are needed.", 16, dialogCaption$ GoTo ErrorSetup End If Else If winSpaceFree < WINSYSNEEDED Then MsgBox "There is not enough disk space on drive " + winDrive$ + ": An estimated" + Str$(WINSYSNEEDED - winSpaceFree) + " additional bytes are needed.", 16, dialogCaption$ GoTo ErrorSetup End If If destSpaceFree < OTHERNEEDED Then MsgBox "There is not enough disk space on drive " + destDrive$ + ": An estimated" + Str$(OTHERNEEDED - destSpaceFree) + " additional bytes are needed.", 16, dialogCaption$ GoTo ErrorSetup End If End If '---------------------------- ' Create destination directory '---------------------------- If Not CreatePath(destPath$) Then GoTo ErrorSetup '----------------------------------------------------------- ' Show Status Dialog -- This stays up while copying files ' It is required by the CopyFile routine '----------------------------------------------------------- ShowStatusDialog dialogCaption$, totalNeeded '----------- ' Copy Files '----------- ' Test to see if loan.exe is on the disk, if not then you know the user ' did not insert the first disk If Not PromptForNextDisk(1, SourcePath$ + "loan.ex_") Then GoTo ErrorSetup ' Install loan.exe and grid.vbx in the destPath$ If Not CopyFile(SourcePath$, destPath$, "loan.ex_", "loan.exe") Then GoTo ErrorSetup If Not CopyFile(SourcePath$, winSysDir$, "grid.vb_", "grid.vbx") Then GoTo ErrorSetup ' If you have more than one distribution disk, call PromptForNextDisk after ' you have installed all the files from the previous disk. This line tests to ' see if foo.da_ is on disk 2. If not, you know the user has not inserted disk 2. ' The call to PromptForNextDisk is commented out, since loan.exe can be installed ' from a single distribution disk. ' If Not PromptForNextDisk(2, SourcePath$ + "foo.da_") Then GoTo ErrorSetup ' If Not CopyFile(SourcePath$, destPath$, "foo.da_", "foo.dat", 0) Then GoTo ErrorSetup '-------------------------------------------------- ' File Copying is over, so unload the status dialog '-------------------------------------------------- Unload StatusDlg '----------------------------------------------------------- ' Show static message while working on DDE to Program Manager '----------------------------------------------------------- ShowStaticMessageDialog dialogCaption$, "Creating Program Manager Icon..." '-------------------------------------- ' Create program manager group and icon '-------------------------------------- CreateProgManGroup Setup1, "My Loan Application", "LOAN.GRP" CreateProgManItem Setup1, destPath$ + "LOAN.EXE", "My Loan Application" '------------------------------------------------- ' Since SETUP.EXE copies your setup program to the Windows ' directory, it is possible for your user to ' execute this program directly. ' ' As a usability feature, you may wish to insert code ' here to install a program manager icon that executes ' your setup program in the windows drive. This ' allows th user to re-run setup at a later time to ' install options that were not installed the first ' time. '------------------------------------------------- '------------------- ' Hide Static Message '------------------- MessageDlg.Hide '------------------ ' Show Final message '------------------ MsgBox APPNAME + " Installation is Complete!", 48, dialogCaption$ ExitSetup: Setup1.Hide RestoreProgMan 'Show the program manager End Exit Sub ErrorSetup: MsgBox APPNAME + " is not properly installed. Please re-run setup at a later time to install the Test Application properly.", 48, dialogCaption$ End Exit Sub End Sub Sub Form_Paint () DrawBackground End Sub '--------------------------------------------------------------- ' Sets the form's caption, Paints 3-D Background Text, Shows Form '--------------------------------------------------------------- Sub ShowMainForm (Caption$) Screen.MousePointer = 11 Setup1.Caption = Caption$ Setup1.Move 0, 0, Screen.Width, Screen.Height * .85 Setup1.Show Setup1.Refresh Setup1.ScaleMode = 2 Setup1.FontSize = 24 Setup1.FontBold = True Setup1.FontItalic = True DrawBackground End Sub Sub ShowPathDialog (title$, caption1$, caption2$, defaultDrive$, defaultText$, SourcePath$, outButton$) Screen.MousePointer = 11 Load PathDlg PathDlg.Caption = title$ PathDlg.Label1.Caption = caption1$ PathDlg.Label2.Caption = caption2$ PathDlg.inDrive.Tag = defaultDrive$ PathDlg.Text1.Text = defaultText$ PathDlg.Text1.SelStart = 0 PathDlg.Text1.SelLength = Len(defaultText$) CenterForm PathDlg Screen.MousePointer = 0 PathDlg.Show 1 SourcePath$ = PathDlg.outPath.Tag outButton$ = PathDlg.outButton.Tag Unload PathDlg End Sub Sub ShowStaticMessageDialog (title$, Caption$) Load MessageDlg CenterForm MessageDlg MessageDlg.Caption = title$ MessageDlg.Label.Caption = Caption$ MessageDlg.Show MessageDlg.Refresh End Sub Sub ShowStatusDialog (title$, totalBytes As Long) Load StatusDlg StatusDlg.Caption = title$ StatusDlg.total.Tag = Str$(totalBytes) CenterForm StatusDlg StatusDlg.Show End Sub