home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l405 / 1.ddi / SETUP1.FR_ / SETUP1.bin (.txt)
Encoding:
Visual Basic Form  |  1993-04-28  |  15.9 KB  |  373 lines

  1. VERSION 2.00
  2. Begin Form Setup1 
  3.    BackColor       =   &H00400000&
  4.    Caption         =   "Test App Setup"
  5.    ClientHeight    =   2130
  6.    ClientLeft      =   1860
  7.    ClientTop       =   2610
  8.    ClientWidth     =   5640
  9.    ControlBox      =   0   'False
  10.    FillStyle       =   0  'Solid
  11.    FontBold        =   -1  'True
  12.    FontItalic      =   -1  'True
  13.    FontName        =   "MS Sans Serif"
  14.    FontSize        =   24
  15.    FontStrikethru  =   0   'False
  16.    FontUnderline   =   0   'False
  17.    ForeColor       =   &H00000000&
  18.    Height          =   2535
  19.    Icon            =   SETUP1.FRX:0000
  20.    Left            =   1800
  21.    LinkMode        =   1  'Source
  22.    LinkTopic       =   "Form3"
  23.    MaxButton       =   0   'False
  24.    MinButton       =   0   'False
  25.    ScaleHeight     =   142
  26.    ScaleMode       =   3  'Pixel
  27.    ScaleWidth      =   376
  28.    Top             =   2265
  29.    Width           =   5760
  30.    Begin Label Label2 
  31.       BorderStyle     =   1  'Fixed Single
  32.       Caption         =   "To customize this setup program, modify the FORM_LOAD event procedure in this form."
  33.       Height          =   435
  34.       Left            =   15
  35.       TabIndex        =   1
  36.       Top             =   15
  37.       Visible         =   0   'False
  38.       Width           =   5625
  39.    End
  40.    Begin Label Label1 
  41.       BorderStyle     =   1  'Fixed Single
  42.       Caption         =   "This label used for DDE connection to the Program Manager"
  43.       Height          =   390
  44.       Left            =   15
  45.       TabIndex        =   0
  46.       Top             =   525
  47.       Visible         =   0   'False
  48.       Width           =   5610
  49.    End
  50. Const APPNAME = "Loan Application"
  51. Const APPDIR = "C:\LOAN"    ' The default install directory
  52. Const fDataAccess% = False
  53. Const fODBC% = False
  54. Const fBtrieve% = False
  55. Const fOLE2% = False
  56. ' Set the total uncompressed file sizes
  57. ' by adding the sizes of the files
  58. Const WINSYSNEEDED = 40896  ' Files that go into WINDOWS and SYSTEM directory
  59. Const OTHERNEEDED = 12555   ' Files that don't go into the WINDOWS or SYSTEM directory
  60. Sub DrawBackground ()
  61.     Setup1.CurrentY = 5
  62.     Setup1.CurrentX = 5
  63.     Setup1.ForeColor = QBColor(15)
  64.     Print APPNAME + " Setup"
  65. End Sub
  66. Sub Form_Load ()
  67.     '----------
  68.     ' Initialize
  69.     '----------
  70.     dialogCaption$ = APPNAME + " Setup"
  71.     ShowMainForm dialogCaption$
  72.     winDrive$ = UCase$(Left$(winDir$, 1))
  73.     winDir$ = UCase$(GetWindowsDir$())
  74.     winSysDir$ = UCase$(GetWindowsSysDir$())
  75.     '----------------------------------------------------
  76.     ' Get Window version
  77.     '----------------------------------------------------
  78.     TheVerInfo& = GetVersion()
  79.     WinVer& = TheVerInfo& And &HFFFF&
  80.     If Val(Format$(WinVer& Mod 256) + "." + Format$(WinVer& \ 256)) >= 3.1 Then
  81.         gfWin31% = True
  82.     End If
  83.     '----------------------------------------------------
  84.     ' OLE 2.0 requires Win 3.1 or greater
  85.     '----------------------------------------------------
  86.     If fOLE2% And Not gfWin31% Then
  87.         MsgBox "This application requires Windows 3.1 or later"
  88.         GoTo ErrorSetup
  89.     End If
  90.     '----------------------------------------------------
  91.     ' SETUP.EXE passes the source drive in a command
  92.     ' argument.  If it is empty,  that means the user
  93.     ' executed this .exe directly.  In that case, show
  94.     ' a dialog to get the desired source directory.
  95.     '----------------------------------------------------
  96.     SourcePath$ = Command$
  97.     If SourcePath$ = "" Then
  98.         title$ = dialogCaption$
  99.         caption1$ = "Please enter the drive or path containing the " + APPNAME + " source files."
  100.         caption2$ = "Install From:"
  101.         defaultDrive$ = "A:"
  102.         defaultText$ = "A:\"
  103.         ShowPathDialog title$, caption1$, caption2$, defaultDrive$, defaultText$, SourcePath$, outButton$
  104.         If outButton$ = "exit" Then GoTo ErrorSetup
  105.     Else
  106.         If Right$(SourcePath$, 1) <> "\" Then
  107.             SourcePath$ = SourcePath$ + "\"
  108.         End If
  109.     End If
  110.     '--------------------
  111.     ' Get Destination Path
  112.     '--------------------
  113.     title$ = dialogCaption$
  114.     caption1$ = "If you want to install the test application in a different directory and/or drive, type the name of the directory."
  115.     caption2$ = "Install To:"
  116.     defaultDrive$ = "C:"
  117.     defaultText$ = APPDIR
  118.     ShowPathDialog title$, caption1$, caption2$, defaultDrive$, defaultText$, destPath$, outButton$
  119.     If outButton$ = "exit" Then GoTo ErrorSetup
  120.     '---------------------
  121.     ' Sample Option Dialog
  122.     '---------------------
  123. '    ReDim Caption(1 To 4) As String
  124. '    ReDim choice(1 To 4) As Integer
  125. '    title$ = dialogCaption$
  126. '    numOptions = 4
  127. '    Caption(1) = "Sample Option 1"
  128. '    Caption(2) = "Sample Option 2"
  129. '    Caption(3) = "Sample Option 3"
  130. '    Caption(4) = "Sample Option 4"
  131. '    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."
  132. '    ShowOptionDialog title$, numOptions, Caption$(), helpTxt$, choice(), outButton$
  133. '    If outButton$ = "exit" Then
  134. '        GoTo ErrorSetup
  135. '    Else
  136. '        If choice(1) Then MsgBox "Option #1 Selected", 48, "SETUP"
  137. '        If choice(2) Then MsgBox "Option #2 Selected", 48, "SETUP"
  138. '        If choice(3) Then MsgBox "Option #3 Selected", 48, "SETUP"
  139. '        If choice(4) Then MsgBox "Option #4 Selected", 48, "SETUP"
  140. '    End If
  141.     '-----------------------------------------
  142.     ' Dim disk space variables as Long Integers
  143.     '-----------------------------------------
  144.     Dim winSpaceFree As Long
  145.     Dim sourceSpaceFree As Long
  146.     Dim destSpaceFree As Long
  147.     Dim totalNeeded As Long
  148.     '---------------------------------------------------------
  149.     ' If the Windows \SYSTEM directory is a subdirectory
  150.     ' of the Windows directory, the proper place for
  151.     ' installation of .VBXs and shared .DLLs is the
  152.     ' Windows \SYSTEM directory.
  153.     '
  154.     ' If the Windows \SYSTEM directory is *not* a subdirectory
  155.     ' of the Windows directory, then the user is running a
  156.     ' shared version of Windows, and the proper place for
  157.     ' installation of .VBXs and shared .DLLs is the
  158.     ' Windows directory.
  159.     '---------------------------------------------------------
  160.     If InStr(winSysDir$, winDir$) = 0 Then
  161.         winSysDir$ = winDir$
  162.     End If
  163.     '---------------------------------
  164.     ' Get Drive Letters of directories
  165.     '---------------------------------
  166.     destDrive$ = UCase$(Left$(destPath$, 1))
  167.     sourceDrive$ = UCase$(Left$(SourcePath$, 1))
  168.     '---------------------------------
  169.     ' Compute free disk space variables
  170.     '---------------------------------
  171.     winSpaceFree = GetDiskSpaceFree(winDrive$)
  172.     destSpaceFree = GetDiskSpaceFree(destDrive$)
  173.     '-----------------------------------------
  174.     ' Check for enough disk space.
  175.     '
  176.     ' Some components are being installed into the
  177.     ' Windows\SYSTEM directory.
  178.     '
  179.     ' So if the main destination path is on a
  180.     ' different drive than the drive with
  181.     ' the Windows \SYSTEM directory, we have to
  182.     ' check both drives.
  183.     '
  184.     ' An example of this is when the user is installing
  185.     ' the main product to drive D:, but the Windows
  186.     ' directory is on drive c:
  187.     ' -----------------------------------------
  188.     totalNeeded = WINSYSNEEDED + OTHERNEEDED
  189.     If winDrive$ = destDrive$ Then
  190.         If destSpaceFree < totalNeeded Then
  191.             MsgBox "There is not enough disk space on drive " + destDrive$ + ":   An estimated" + Str$(totalNeeded - destSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  192.             GoTo ErrorSetup
  193.         End If
  194.     Else
  195.         If winSpaceFree < WINSYSNEEDED Then
  196.             MsgBox "There is not enough disk space on drive " + winDrive$ + ":  An estimated" + Str$(WINSYSNEEDED - winSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  197.             GoTo ErrorSetup
  198.         End If
  199.         If destSpaceFree < OTHERNEEDED Then
  200.             MsgBox "There is not enough disk space on drive " + destDrive$ + ":  An estimated" + Str$(OTHERNEEDED - destSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  201.             GoTo ErrorSetup
  202.         End If
  203.         
  204.     End If
  205.     '----------------------------
  206.     ' Create destination directory
  207.     '----------------------------
  208.     If Not CreatePath(destPath$) Then GoTo ErrorSetup
  209.     '-----------------------------------------------------------
  210.     ' Show Status Dialog -- This stays up while copying files
  211.     ' It is required by the CopyFile routine
  212.     '-----------------------------------------------------------
  213.     ShowStatusDialog dialogCaption$, totalNeeded
  214.     '-----------
  215.     ' Copy Files
  216.     '-----------
  217.     ' Test to see if loan.exe is on the disk, if not then you know the user
  218.     ' did not insert the first disk
  219.     If Not PromptForNextDisk(1, SourcePath$ + "loan.ex_") Then GoTo ErrorSetup
  220.     ' Install loan.exe and grid.vbx in the destPath$
  221.     If Not CopyFile(SourcePath$, destPath$, "loan.ex_", "loan.exe") Then GoTo ErrorSetup
  222.     If Not CopyFile(SourcePath$, winSysDir$, "grid.vb_", "grid.vbx") Then GoTo ErrorSetup
  223.     ' If you have more than one distribution disk, call PromptForNextDisk after
  224.     ' you have installed all the files from the previous disk. This line tests to
  225.     ' see if foo.da_ is on disk 2. If not, you know the user has not inserted disk 2.
  226.     ' The call to PromptForNextDisk is commented out, since loan.exe can be installed
  227.     ' from a single distribution disk.
  228.     ' If Not PromptForNextDisk(2, SourcePath$ + "foo.da_") Then GoTo ErrorSetup
  229.     ' If Not CopyFile(SourcePath$, destPath$, "foo.da_", "foo.dat", 0) Then GoTo ErrorSetup
  230.     '--------------------------------------------------
  231.     ' File Copying is over, so unload the status dialog
  232.     '--------------------------------------------------
  233.     Unload StatusDlg
  234.     '-----------------------------------------------------------
  235.     ' Show static message while working on DDE to Program Manager
  236.     '-----------------------------------------------------------
  237.     ShowStaticMessageDialog dialogCaption$, "Creating Program Manager Icon..."
  238.     '--------------------------------------
  239.     ' Create program manager group and icon
  240.     '--------------------------------------
  241.     CreateProgManGroup Setup1, "My Loan Application", "LOAN.GRP"
  242.     CreateProgManItem Setup1, destPath$ + "LOAN.EXE", "My Loan Application"
  243.     '-------------------------------------------------
  244.     ' Since SETUP.EXE copies your setup program to the Windows
  245.     ' directory, it is possible for your user to
  246.     ' execute this program directly.
  247.     '
  248.     ' As a usability feature, you may wish to insert code
  249.     ' here to install a program manager icon that executes
  250.     ' your setup program in the windows drive.  This
  251.     ' allows th user to re-run setup at a later time to
  252.     ' install options that were not installed the first
  253.     ' time.
  254.     '-------------------------------------------------
  255.     '-------------------
  256.     ' Hide Static Message
  257.     '-------------------
  258.     MessageDlg.Hide
  259.     '--------------------------------------------------------------
  260.     ' If OLE2.DLL already exists, then ignore the OLE 2 flag.
  261.     ' Otherwise, if we are installing an application that uses
  262.     ' OLE 2.0, we need to register the OLE 2 DLL's via REGEDIT.EXE.
  263.     '
  264.     ' Do not copy OLE dlls unless you check the versions and assure
  265.     ' that the versions you plan to install postdate the ones on
  266.     ' the users machine.
  267.     '
  268.     '
  269.     ' The data access engine and OLE 2.0 need to have SHARE.EXE
  270.     ' loaded. Check AUTOEXEC.BAT and add if needed.  NOTE: If
  271.     ' running Window For WorkGroup, then do not add SHARE.  WFW
  272.     ' use its own sharing mechanism, VSHARE.386.
  273.     '----------------------------------------------------------
  274.     If fDataAccess% Or fOLE2% And Not FileExists(winSysDir$ + "\" + "OLE2.DLL") Then
  275.         ret$ = Space$(255)
  276.         x% = GetPrivateProfileString("BOOT", "NETWORK.DRV", "", ret$, Len(ret$), "SYSTEM.INI")
  277.         If x% Then ret$ = Left(ret$, x%)
  278.         If InStr(1, UCase$(ret$), "WFWNET.DRV") = 0 Then
  279.             AddShareIfNeeded winSysDir$, "SHARE.EXE"
  280.         End If
  281.     End If
  282.     '----------------------------
  283.     ' Need to register OLE 2.0 dlls
  284.     '----------------------------
  285.     If fOLE2% And Not FileExists(winSysDir$ + "\" + "OLE2.DLL") Then
  286.         x% = Shell("regedit /s ole2.reg")
  287.     End If
  288.     '-------------------------------------------------------
  289.     ' Do not change this if statement.  Used by Setup Wizard
  290.     '-------------------------------------------------------
  291.     If fODBC% Then
  292.         CreateProgManItem Setup1, destPath$ + "ODBCADM.EXE", "ODBC Administrator"
  293.         MsgBox "Before you can run a Visual Basic ODBC application using the SQL Server driver, you must first update the ODBC catalog of stored procedures.  These procedures are provided in the INSTCAT.SQL file.  Typically, the system administrator for SQL Server should install these procedures, using the SQL Server ISQL utility."
  294.     End If
  295.     '-------------------------------------------------------
  296.     ' Do not change this if statement.  Used by Setup Wizard
  297.     '-------------------------------------------------------
  298.     If fBtrieve% Then
  299.         ' See notes in Appendix C
  300.         retstr$ = String$(255, 32)
  301.         x% = GetPrivateProfileString%("BTRIEVE", "OPTIONS", "1", retstr$, Len(retstr$), "WIN.INI")
  302.         If x% <= 1 Then
  303.             x% = WritePrivateProfileString%("BTRIEVE", "OPTIONS", "/m:64 /p:4096 /b:16 /f:20 /l:40 /n:12 /t:" + destPath$ + "BTRIEVE.TRN", "WIN.INI")
  304.         End If
  305.     End If
  306.     '------------------
  307.     ' Show Final message
  308.     '------------------
  309.     MsgBox APPNAME + " Installation is Complete!", 48, dialogCaption$
  310. ExitSetup:
  311.     Setup1.Hide
  312.     RestoreProgMan         'Show the program manager
  313.     End
  314.     Exit Sub
  315. ErrorSetup:
  316.     MsgBox APPNAME + " is not properly installed.  Please re-run setup at a later time to install the Test Application properly.", 48, dialogCaption$
  317.     ChDrive winDrive$   ' Set back to hard disk
  318.     ChDir Left$(winDir$, Len(winDir$) - 1)
  319.     End
  320.     Exit Sub
  321. End Sub
  322. Sub Form_Paint ()
  323.     DrawBackground
  324. End Sub
  325. '---------------------------------------------------------------
  326. ' Sets the form's caption, Paints 3-D Background Text, Shows Form
  327. '---------------------------------------------------------------
  328. Sub ShowMainForm (Caption$)
  329.     Screen.MousePointer = 11
  330.     Setup1.Caption = Caption$
  331.     Setup1.Move 0, 0, Screen.Width, Screen.Height * .85
  332.     Setup1.Show
  333.     Setup1.Refresh
  334.     Setup1.ScaleMode = 2
  335.     Setup1.FontSize = 24
  336.     Setup1.FontBold = True
  337.     Setup1.FontItalic = True
  338.     DrawBackground
  339. End Sub
  340. Sub ShowPathDialog (title$, caption1$, caption2$, defaultDrive$, defaultText$, SourcePath$, outButton$)
  341.         Screen.MousePointer = 11
  342.         Load PathDlg
  343.         PathDlg.Caption = title$
  344.         PathDlg.Label1.Caption = caption1$
  345.         PathDlg.Label2.Caption = caption2$
  346.         PathDlg.inDrive.Tag = defaultDrive$
  347.         PathDlg.Text1.Text = defaultText$
  348.         PathDlg.Text1.SelStart = 0
  349.         PathDlg.Text1.SelLength = Len(defaultText$)
  350.         CenterForm PathDlg
  351.         Screen.MousePointer = 0
  352.         PathDlg.Show 1
  353.         
  354.         SourcePath$ = PathDlg.outPath.Tag
  355.         outButton$ = PathDlg.outButton.Tag
  356.         Unload PathDlg
  357. End Sub
  358. Sub ShowStaticMessageDialog (title$, Caption$)
  359.     Load MessageDlg
  360.     CenterForm MessageDlg
  361.     MessageDlg.Caption = title$
  362.     MessageDlg.Label.Caption = Caption$
  363.     MessageDlg.Show
  364.     MessageDlg.Refresh
  365. End Sub
  366. Sub ShowStatusDialog (title$, totalBytes As Long)
  367.     Load StatusDlg
  368.     StatusDlg.Caption = title$
  369.     StatusDlg.total.Tag = Str$(totalBytes)
  370.     CenterForm StatusDlg
  371.     StatusDlg.Show
  372. End Sub
  373.