home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / cusgen12 / custom.txt < prev    next >
Text File  |  1993-03-03  |  5KB  |  132 lines

  1. '------------------------------------
  2. 'Initialize all variables here
  3. '------------------------------------
  4. Prognam$ = ""
  5. defdrivesrc$ = "A:"
  6. defpathsrc$ = "A:\"
  7. defdrivedes$ = "C:"
  8. defpathdes$ = "C:\PATH"
  9. proggrp$ = "FILENAME.GRP"
  10. numprog = "1"
  11. ReDim progexe$(1 To numprog)
  12. ReDim progtitle$(1 To numprog)
  13. progexe$(1) = "FILENAME.EXE"
  14. progtitle$(1) = "TITLE"
  15. Dim winSpaceFree as Long
  16. Dim sourceSpaceFree as Long
  17. Dim destSpaceFree as Long
  18. Dim totalNeeded as Long
  19. Dim otherneeded as Long
  20. Dim winSysNeeded as Long
  21. winSysNeeded = 999999
  22. otherneeded = 999999
  23. totalNeeded = 1999998
  24. dialogCaption$ = prognam$ + " Setup"
  25. ShowMainForm dialogCaption$
  26. sourcepath$ = Command$
  27. If sourcepath$ = "" Then
  28.    title$ = dialogCaption$
  29.    caption1$ = "Please enter the drive or path containing the " + prognam$ + "Application source files."
  30.    caption2$ = "Install From:"
  31.    defaultDrive$ = defdrivesrc$
  32.    defaultText$ = defpathsrc$
  33.    ShowPathDialog title$, caption1$, caption2$, defaultDrive$, defaultText$, sourcepath$, outButton$
  34.    If outButton$ = "exit" Then GoTo errorsetup
  35. Else
  36.    If Right$(sourcepath$, 1) <> "\" Then
  37.       sourcepath$ = sourcepath$ + "\"
  38.    End If
  39. End If
  40. title$ = dialogCaption$
  41. caption1$ = "If you want to install " + prognam$ + " in a different directory and/or drive, type the name of the directory."
  42. caption2$ = "Install To:"
  43. defaultDrive$ = defdrivedes$
  44. defaultText$ = defpathdes$
  45. ShowPathDialog title$, caption1$, caption2$, defaultDrive$, defaultText$, destPath$, outButton$
  46. If outButton$ = "exit" Then GoTo errorsetup
  47. winDir$ = GetWindowsDir$()
  48. winsysdir$ = GetWindowsSysDir$()
  49. If InStr(winsysdir$, winDir$) = 0 Then
  50.    winsysdir$ = winDir$
  51. End If
  52. winDrive$ = UCase$(Left$(winDir$, 1))
  53. destDrive$ = UCase$(Left$(destPath$, 1))
  54. sourceDrive$ = UCase$(Left$(sourcepath$, 1))
  55. winSpaceFree = GetDiskSpaceFree(winDrive$)
  56. destSpaceFree = GetDiskSpaceFree(destDrive$)
  57. If winDrive$ = destDrive$ Then
  58.    If destSpaceFree < totalNeeded Then
  59.       MsgBox "There is not enough disk space on drive " + destDrive$ + ":   An estimated" + Str$(totalNeeded - destSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  60.       GoTo errorsetup
  61.    End If
  62. Else
  63.    If winSpaceFree < winSysNeeded Then
  64.       MsgBox "There is not enough disk space on drive " + winDrive$ + ":  An estimated" + Str$(winSysNeeded - winSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  65.       GoTo errorsetup
  66.    End If
  67.    If destSpaceFree < otherneeded Then
  68.       MsgBox "There is not enough disk space on drive " + destDrive$ + ":  An estimated" + Str$(otherneeded - destSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  69.       GoTo errorsetup
  70.    End If
  71. End If
  72. If Not CreatePath(destPath$) Then GoTo errorsetup
  73. ShowStatusDialog dialogCaption$, totalNeeded
  74. hinum = 0
  75. noitems = 0
  76. ReDIm item$(1 to hinum, 1 to noitems)   
  77. ReDim noitem(1 to hinum)
  78. For xxx = 1 To hinum
  79.    For yyy = 1 To noitem(xxx)
  80.       itemm$ = RTrim$(item$(xxx, yyy))
  81.       lngth = Len(itemm$)
  82.       itemm$ = Right$(itemm$, lngth - 3)
  83.       If UCase$(Right$(itemm$, 3)) = "VBX" Or UCase$(Right$(itemm$, 3)) = "DLL" Then
  84.          dest$ = winsysdir$
  85.       Else
  86.          dest$ = destpath$
  87.       End If
  88.       If UCase$(rtrim$(ltrim$(itemm$))) = "SETUPKIT.DLL" Then
  89.          dest$ = destpath$
  90.       End If
  91.    If Not CopyFile(sourcepath$, dest$, itemm$, 0) Then GoTo errorsetup
  92.    Next yyy
  93.    If hinum > 1 and xxx <> hinum Then
  94.       title$ = prognam$ + " Setup"
  95.       msg$ = "Please insert Disk # " + LTrim$(Str$(xxx + 1)) + "on " + sourcepath$
  96.       r% = MsgBox(msg$, 36, title$)
  97.       If r% <> 6 Then
  98.          GoTo errorsetup
  99.       End If
  100.    End If
  101. Next xxx
  102. If hinum > 1 Then
  103.    title$ = prognam$ + " Setup"
  104.    msg$ = "Please insert the Setup Disk # 1 in " + sourcepath$
  105.    r% = MsgBox(msg$, 36, title$)
  106.       If r% <> 6 Then
  107.          GoTo errorsetup
  108.    End If
  109. End If
  110. complete:
  111.    Unload StatusDlg
  112. ShowStaticMessageDialog dialogCaption$, " Creating Program Manager Icon..."
  113. CreateProgManGroup setup1, prognam$, proggrp$
  114. For numicon = 1 To numprog
  115.    CreateProgManItem setup1, destPath$ + progexe$(numicon), progtitle$(numicon)
  116. Next numicon
  117. MessageDlg.Hide
  118. msg$ = prognam$ + " Installation is complete!"
  119. MsgBox msg$, 48, dialogCaption$
  120. ExitSetup:
  121. setup1.Hide
  122. RestoreProgMan
  123. Unload setup1
  124. End
  125. Exit Sub
  126. errorsetup:
  127. msg$ = prognam$ + "is not properly installed. Please re-run setup at a later time to install the" + prognam$ + " Application properly."
  128. MsgBox msg$, 48, dialogCaption$
  129. Unload setup1
  130. Exit Sub
  131. End
  132.