home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Today (BR) Volume 4 #14 / CDRTODAY.iso / SETUP1.BAS < prev    next >
BASIC Source File  |  1997-12-24  |  22KB  |  676 lines

  1.  
  2. Sub AddShareIfNeeded (SharePath$, ShareFile$)
  3.     On Error GoTo ShareError
  4.  
  5.     fh% = FreeFile
  6.     Open "C:\AUTOEXEC.BAT" For Input As fh%
  7.  
  8.     fFound% = 0
  9.     While Not fFound% And Not EOF(fh%)
  10.     Line Input #fh%, Temp1$
  11.     If InStr(1, UCase$(Temp1$), "REM") = 0 And InStr(1, Temp1$, ";") = 0 And InStr(1, UCase$(Temp1$), "SHARE") > 0 Then
  12.        fFound% = True
  13.     End If
  14.     Wend
  15.  
  16.     Close #fh%
  17.  
  18.     If Not fFound% Then
  19.     MsgBox "Please add <PATH>SHARE.EXE /L:500 to your AUTOEXEC.BAT"
  20.     End If
  21.  
  22.     Exit Sub
  23. ShareError:
  24.     Close #fh%, #fh2%
  25.     Exit Sub
  26. End Sub
  27.  
  28. '-------------------------------------------------------
  29. ' Centers the passed form just above center on the screen
  30. '-------------------------------------------------------
  31. Sub CenterForm (x As Form)
  32.   
  33.     'Screen.MousePointer = 11
  34.     x.Top = (Screen.Height * .85) / 2 - x.Height / 2
  35.     x.Left = Screen.Width / 2 - x.Width / 2
  36.     'Screen.MousePointer = 0
  37.  
  38. End Sub
  39.  
  40. '
  41. 'Funcao retorna true se o arquivo Θ mais antigo
  42. '               e for menor
  43. '
  44. 'FileDate1, Arquivo do usuario
  45. 'FileDate2, Arquivo de origem
  46. 'Tamanho1,  Arquivo do usuario
  47. 'Tamanho2,  Arquivo de origem
  48. '
  49. '
  50. '
  51. Function ComparaVersoes (FileDate1, FileDate2, Tamanho1, Tamanho2)
  52.     If FileDate1 <= FileDate2 Then
  53.     If Tamanho1 < Tamanho2 Then
  54.         ComparaVersoes = True
  55.     Else
  56.         ComparaVersoes = False
  57.     End If
  58.     Else
  59.     ComparaVersoes = False
  60.     End If
  61.     
  62. End Function
  63.  
  64. Sub ConcatSplitFiles (firstfile$, cSplit%)
  65.     Dim x%, fh1%, fh2%, outfile$, outfileLen&, CopyLeftOver&, CopyChunk#, filevar$
  66.     Dim iFileMax%, iFile%, y%
  67.  
  68.     For x% = 2 To cSplit%
  69.     
  70.     fh1% = FreeFile
  71.     Open Left$(firstfile$, Len(firstfile$) - 1) + Format$(1) For Binary As fh1%
  72.         
  73.     fh2% = FreeFile
  74.     outfile$ = Left$(firstfile$, Len(firstfile$) - 1) + Format$(x%)
  75.     Open outfile$ For Binary As fh2%
  76.         
  77.     ' Goto the end of file (plus one bytes) to start writing data
  78.     Seek #fh1%, LOF(fh1%) + 1
  79.  
  80.     outfileLen& = LOF(fh2%)
  81.     CopyLeftOver& = outfileLen& Mod 10
  82.     CopyChunk# = (outfileLen& - CopyLeftOver&) / 10
  83.     filevar$ = String$(CopyLeftOver&, 32)
  84.     Get #fh2%, , filevar$
  85.     Put #fh1%, , filevar$
  86.     filevar$ = String$(CopyChunk#, 32)
  87.     iFileMax% = 10
  88.     For iFile% = 1 To iFileMax%
  89.         Get #fh2%, , filevar$
  90.         Put #fh1%, , filevar$
  91.     Next iFile%
  92.  
  93.     Close fh1%, fh2%
  94.     'y% = SetTime(outfile$, firstfile$) Camom
  95.     Kill outfile$
  96.  
  97.     Next x%
  98.     
  99.     FileCopy Left$(firstfile$, Len(firstfile$) - 1) + Format$(1), firstfile$
  100.     Kill Left$(firstfile$, Len(firstfile$) - 1) + Format$(1)
  101. End Sub
  102.  
  103. '---------------------------------------------------------------
  104. ' Copies file SrcFilename from SourcePath to DestinationPath.
  105. '
  106. ' Returns 0 if it could not find the file, or other runtime
  107. ' error occurs.  Otherwise, returns true.
  108. '
  109. ' If the source file is older, the function returns success (-1)
  110. ' even though no file was copied, since no error occurred.
  111. '---------------------------------------------------------------
  112. Function copyFile (ByVal SourcePath As String, ByVal SrcFilename As String, ByVal DestinationPath As String, ByVal DestFileName As String)
  113. ' ----- VerInstallFile() flags -----
  114.     Const VIFF_FORCEINSTALL% = &H1, VIFF_DONTDELETEOLD% = &H2
  115.     Const OF_DELETE% = &H200
  116.     Const VIF_TEMPFILE& = &H1
  117.     Const VIF_MISMATCH& = &H2
  118.     Const VIF_SRCOLD& = &H4
  119.  
  120.     Const VIF_DIFFLANG& = &H8
  121.     Const VIF_DIFFCODEPG& = &H10
  122.     Const VIF_DIFFTYPE& = &H20
  123.     Const VIF_WRITEPROT& = &H40
  124.     Const VIF_FILEINUSE& = &H80
  125.     Const VIF_OUTOFSPACE& = &H100
  126.     Const VIF_ACCESSVIOLATION& = &H200
  127.     Const VIF_SHARINGVIOLATION = &H400
  128.     Const VIF_CANNOTCREATE = &H800
  129.     Const VIF_CANNOTDELETE = &H1000
  130.     Const VIF_CANNOTRENAME = &H2000
  131.     Const VIF_CANNOTDELETECUR = &H4000
  132.     Const VIF_OUTOFMEMORY = &H8000
  133.  
  134.     Const VIF_CANNOTREADSRC = &H10000
  135.     Const VIF_CANNOTREADDST = &H20000
  136.  
  137.     Const VIF_BUFFTOOSMALL = &H40000
  138.     Dim TmpOFStruct As OFStruct
  139.     On Error GoTo ErrorCopy
  140.  
  141.     'Screen.MousePointer = 11
  142.  
  143.     '--------------------------------------
  144.     ' Add ending \ symbols to path variables
  145.     '--------------------------------------
  146.     If Right$(SourcePath$, 1) <> "\" Then
  147.     SourcePath$ = SourcePath$ + "\"
  148.     End If
  149.     If Right$(DestinationPath$, 1) <> "\" Then
  150.     DestinationPath$ = DestinationPath$ + "\"
  151.     End If
  152.     
  153.     '----------------------------
  154.     ' Update status dialog info
  155.     '----------------------------
  156.     Statusdlg.Label1.Caption = "Arquivo de origem: " + Chr$(10) + Chr$(13) + UCase$(SourcePath$ + SrcFilename$)
  157.     Statusdlg.Label1.Refresh
  158.     Statusdlg.Label2.Caption = "Arquivo de destino: " + Chr$(10) + Chr$(13) + UCase$(DestinationPath$ + DestFileName$)
  159.     Statusdlg.Label2.Refresh
  160.  
  161.     '-----------------------------------------
  162.     ' Check the validity of the path and file
  163.     '-----------------------------------------
  164. CheckForExist:
  165.     If Not fileExist(SourcePath$ + SrcFilename$) Then
  166.     'Screen.MousePointer = 0
  167.     x% = MsgBox("Error occurred while attempting to copy file.  Could not locate file: """ + SourcePath$ + SrcFilename$ + """", 34, "SETUP")
  168.     'Screen.MousePointer = 11
  169.     If x% = 3 Then
  170.         copyFile = False
  171.     ElseIf x% = 4 Then
  172.         GoTo CheckForExist
  173.     ElseIf x% = 5 Then
  174.         GoTo SkipThisFile
  175.     End If
  176.     Else
  177.     '-------------------------------------------------
  178.     ' VerInstallFile installs the file. We need to initialize
  179.     ' some arguments for the temp file that is created by the call
  180.     '-------------------------------------------------
  181. TryToCopyAgain:
  182.     CurrDir$ = String$(255, 0)
  183.     TmpFile$ = String$(255, 0)
  184.     lpwTempFileLen% = 255
  185.     InFileVer$ = GetFileVersion(SourcePath$ + SrcFilename$)
  186.     OutFileVer$ = GetFileVersion(DestinationPath$ + DestFileName$)
  187.     
  188.     ' Install if no version info is available
  189.     If Len(InFileVer$) <> 0 And Len(OutFileVer$) <> 0 Then
  190.         ' Don't install older or same version of file
  191.         If InFileVer$ <= OutFileVer$ Then
  192.         updatestatus GetFileSize(SourcePath$ + SrcFilename$)
  193.         copyFile = True
  194.         Exit Function
  195.         End If
  196.     End If
  197.     
  198.     Result& = VerInstallFile&(0, SrcFilename$, DestFileName$, SourcePath$, DestinationPath$, CurrDir$, TmpFile$, lpwTempFileLen%)
  199.  
  200.     '--------------------------------------------
  201.     ' After copying, update the installation meter
  202.     '---------------------------------------------
  203.     
  204.     S$ = DestinationPath$
  205.     If Right$(S$, 1) <> "\" Then S$ = S$ + "\"
  206.     S$ = S$ + DestFileName$
  207.     If Not TryAgain% Then updatestatus GetFileSize(S$)
  208.  
  209.     '--------------------------------
  210.     ' There are many return values that you can test for.
  211.     ' The constants are listed above.
  212.     ' The following lines of code return will set the Function to
  213.     ' True if the VerInstallFile call was successful.
  214.     '
  215.     ' If the call was unsuccessful due to a different language on the
  216.     ' users machine, VerInstallFile is called again to force installation.
  217.     ' You can change this to not install if you choose.
  218.     ' Be careful about using FORCEINSTALL.  Other flags could be
  219.     ' set which indicate that this file should not be overridden.
  220.     '
  221.     ' Under any other circumstance, the tempfile created by VerInstallFile
  222.     ' is removed using OpenFile and the CopyFile function returns false.
  223.     '--------------------------------------------------------
  224.     
  225.     If Result& = 0 Or (Result& And VIF_SRCOLD&) = VIF_SRCOLD& Then
  226.         copyFile = True
  227.     ElseIf (Result& And VIF_DIFFLANG&) = VIF_DIFFLANG& Then
  228.         Result& = VerInstallFile&(VIFF_FORCEINSTALL%, SrcFilename$, DestFileName$, SourcePath$, DestinationPath$, CurrDir$, TmpFile$, lpwTempFileLen%)
  229.         copyFile = True
  230.     ElseIf (Result& And VIF_WRITEPROT&) = VIF_WRITEPROT& Then
  231.         Result& = VerInstallFile&(VIFF_FORCEINSTALL%, SrcFilename$, DestFileName$, SourcePath$, WinSysDir$ + "\", CurrDir$, TmpFile$, lpwTempFileLen%)
  232.         copyFile = True
  233.     ElseIf (Result& And VIF_CANNOTREADSRC) = VIF_CANNOTREADSRC Then
  234.         ' VerInstallFile does will not handle compressed files that have been split.
  235.         ' Use VB's FileCopy stmt
  236.         FileCopy SourcePath$ + SrcFilename$, DestinationPath$ + DestFileName$
  237.         copyFile = True
  238.     Else
  239.         'Screen.MousePointer = 0
  240.         If (Result& And VIF_FILEINUSE&) = VIF_FILEINUSE& Then
  241.         x% = MsgBox(DestFileName$ & " is in use. Please close all applications and re-attempt Setup.", 34)
  242.         If x% = 3 Then
  243.             copyFile = False
  244.         ElseIf x% = 4 Then
  245.             TryAgain% = True
  246.             GoTo TryToCopyAgain
  247.         ElseIf x% = 5 Then
  248.             copyFile = True
  249.             GoTo SkipThisFile
  250.         End If
  251.         Else
  252.         MsgBox DestFileName$ & " could not be installed."
  253.         copyFile = False
  254.         End If
  255.         'Screen.MousePointer = 11
  256.     End If
  257.  
  258.     If (Result& And VIF_TEMPFILE&) = VIF_TEMPFILE& Then copyresult% = OpenFile(TmpFile$, TmpOFStruct, OF_DELETE%)
  259.        'Screen.MousePointer = 0
  260.        Exit Function
  261.     End If
  262.  
  263. SkipThisFile:
  264.        Exit Function
  265. ErrorCopy:
  266.     copyFile = False
  267.     'Screen.MousePointer = 0
  268.     Exit Function
  269.  
  270. End Function
  271.  
  272. '---------------------------------------------
  273. ' Create the path contained in DestPath$
  274. ' First char must be drive letter, followed by
  275. ' a ":\" followed by the path, if any.
  276. '---------------------------------------------
  277. Function createpath (ByVal DestPath$) As Integer
  278.     'Screen.MousePointer = 11
  279.  
  280.     '---------------------------------------------
  281.     ' Add slash to end of path if not there already
  282.     '---------------------------------------------
  283.     If Right$(DestPath$, 1) <> "\" Then
  284.     DestPath$ = DestPath$ + "\"
  285.     End If
  286.       
  287.  
  288.     '-----------------------------------
  289.     ' Change to the root dir of the drive
  290.     '-----------------------------------
  291.     On Error Resume Next
  292.     ChDrive DestPath$
  293.     If Err <> 0 Then GoTo errorOut
  294.     ChDir "\"
  295.  
  296.     '-------------------------------------------------
  297.     ' Attempt to make each directory, then change to it
  298.     '-------------------------------------------------
  299.     BackPos = 3
  300.     forePos = InStr(4, DestPath$, "\")
  301.     Do While forePos <> 0
  302.     temp$ = Mid$(DestPath$, BackPos + 1, forePos - BackPos - 1)
  303.  
  304.     Err = 0
  305.     MkDir temp$
  306.     If Err <> 0 And Err <> 75 Then GoTo errorOut
  307.  
  308.     Err = 0
  309.     ChDir temp$
  310.     If Err <> 0 Then GoTo errorOut
  311.  
  312.     BackPos = forePos
  313.     forePos = InStr(BackPos + 1, DestPath$, "\")
  314.     Loop
  315.          
  316.     createpath = True
  317.     'Screen.MousePointer = 0
  318.     Exit Function
  319.          
  320. errorOut:
  321.     MsgBox "Erro enquanto tentava criar o diret≤rio." & Chr(10) & UCase(DestPath$), 48
  322.     createpath = False
  323.     'Screen.MousePointer = 0
  324.  
  325. End Function
  326.  
  327. Function defineMeuDirTrab ()
  328.     defineMeuDirTrab = definemeupath() & "TRAB\"
  329. End Function
  330.  
  331. Function defineMeuPath ()
  332.     meuPath = app.Path
  333.     If Right(meuPath, 1) <> "\" Then
  334.     meuPath = meuPath & "\"
  335.     End If
  336.     defineMeuPath = meuPath
  337. End Function
  338.  
  339. '----------------------------------------------------------
  340. ' Check for the existence of a file by attempting an OPEN.
  341. '----------------------------------------------------------
  342. Function fileExist (Path$) As Integer
  343.  
  344.     x = FreeFile
  345.  
  346.     On Error Resume Next
  347.     Open Path$ For Input As x
  348.     If Err = 0 Then
  349.     fileExist = True
  350.     Else
  351.     fileExist = False
  352.     End If
  353.     Close x
  354.  
  355. End Function
  356.  
  357. '------------------------
  358. ' Get the size of the file
  359. '------------------------
  360. Function GetFileSize (source$) As Long
  361.     x = FreeFile
  362.     Open source$ For Binary Access Read As x
  363.     GetFileSize = LOF(x)
  364.     Close x
  365. End Function
  366.  
  367. Function GetFileVersion (FileToCheck As String) As String
  368.     On Error Resume Next
  369.     VersionInfoSize& = GetFileVersionInfoSize(FileToCheck, lpdwHandle&)
  370.     If VersionInfoSize& = 0 Then
  371.     GetFileVersion = ""
  372.     Exit Function
  373.     End If
  374.     lpvdata$ = String(VersionInfoSize&, Chr$(0))
  375.     VersionInfo% = GetFileVersionInfo(FileToCheck, lpdwHandle&, VersionInfoSize&, lpvdata$)
  376.     ptrFixed% = VerQueryValue(lpvdata$, "\FILEVERSION", lplpBuffer&, lpcb%)
  377.     If ptrFixed% = 0 Then
  378.     ' Take a shot with the hardcoded TransString
  379.     TransString$ = "040904E4"
  380.     ptrString% = VerQueryValue(lpvdata$, "\StringFileInfo\" & TransString$ & "\CompanyName", lplpBuffer&, lpcb%)
  381.     If ptrString% <> 0 Then GoTo GetValues
  382.     ptrFixed% = VerQueryValue(lpvdata$, "\", lplpBuffer&, lpcb%)
  383.     If ptrFixed% = 0 Then
  384.         GetFileVersion = ""
  385.         Exit Function
  386.     Else
  387.         TransString$ = ""
  388.         fixedstr$ = String(lpcb% + 1, Chr(0))
  389.         stringcopy& = lstrcpyn(fixedstr$, lplpBuffer&, lpcb% + 1)
  390.         For i = lpcb% To 1 Step -1
  391.         char$ = Hex(Asc(Mid(fixedstr$, i, 1)))
  392.         If Len(char$) = 1 Then
  393.             char$ = "0" + char$
  394.         End If
  395.         TransString$ = TransString$ + char$
  396.         If Len(TransString$ & nextchar$) Mod 8 = 0 Then
  397.             TransString$ = "&H" & TransString$
  398.             TransValue& = Val(TransString$)
  399.             TransString$ = ""
  400.         End If
  401.         Next i
  402.     End If
  403.     End If
  404.     TransTable$ = String(lpcb% + 1, Chr(0))
  405.     TransString$ = String(0, Chr(0))
  406.     stringcopy& = lstrcpyn(TransTable$, lplpBuffer&, lpcb% + 1)
  407.     For i = 1 To lpcb%
  408.     char$ = Hex(Asc(Mid(TransTable$, i, 1)))
  409.     If Len(char$) = 1 Then
  410.         char$ = "0" + char$
  411.     End If
  412.     If Len(TransString$ & nextchar$) Mod 4 = 0 Then
  413.         nextchar$ = char$
  414.     Else
  415.         TransString$ = TransString$ + char$ + nextchar$
  416.         nextchar$ = ""
  417.         char$ = ""
  418.     End If
  419.     Next i
  420. GetValues:
  421.     ptrString% = VerQueryValue(lpvdata$, "\StringFileInfo\" & TransString$ & "\FileVersion", lplpBuffer&, lpcb%)
  422.     If ptrString% = 1 Then
  423.     TransTable$ = String(lpcb%, Chr(0))
  424.     stringcopy& = lstrcpyn(TransTable$, lplpBuffer&, lpcb% + 1)
  425.     GetFileVersion = TransTable$
  426.     Else
  427.     GetFileVersion = ""
  428.     End If
  429. End Function
  430.  
  431. '---------------------------------------------------------
  432. ' Calls the windows API to get the windows\SYSTEM directory
  433. '---------------------------------------------------------
  434. Function getWindowsSysdir () As String
  435.     temp$ = String$(145, 0)                 ' Size Buffer
  436.     x = GetSystemDirectory(temp$, 145)      ' Make API Call
  437.     temp$ = Left$(temp$, x)                 ' Trim Buffer
  438.  
  439.     If Right$(temp$, 1) <> "\" Then         ' Add \ if necessary
  440.     getWindowsSysdir$ = temp$ + "\"
  441.     Else
  442.     getWindowsSysdir$ = temp$
  443.     End If
  444. End Function
  445.  
  446. '------------------------------------------------------
  447. ' Function:   IsValidPath as integer
  448. ' arguments:  DestPath$         a string that is a full path
  449. '             DefaultDrive$     the default drive.  eg.  "C:"
  450. '
  451. '  If DestPath$ does not include a drive specification,
  452. '  IsValidPath uses Default Drive
  453. '
  454. '  When IsValidPath is finished, DestPath$ is reformated
  455. '  to the format "X:\dir\dir\dir\"
  456. '
  457. ' Result:  True (-1) if path is valid.
  458. '          False (0) if path is invalid
  459. '-------------------------------------------------------
  460. Function isvalidPath (DestPath$, ByVal DefaultDrive$) As Integer
  461.  
  462.     '----------------------------
  463.     ' Remove left and right spaces
  464.     '----------------------------
  465.     DestPath$ = RTrim$(LTrim$(DestPath$))
  466.     
  467.  
  468.     '-----------------------------
  469.     ' Check Default Drive Parameter
  470.     '-----------------------------
  471.     If Right$(DefaultDrive$, 1) <> ":" Or Len(DefaultDrive$) <> 2 Then
  472.     'MsgBox "Bad default drive parameter specified in IsValidPath Function.  You passed,  """ + DefaultDrive$ + """.  Must be one drive letter and "":"".  For example, ""C:"", ""D:""...", 64, "Setup Kit Error"
  473.     GoTo parseErr
  474.     End If
  475.     
  476.  
  477.     '-------------------------------------------------------
  478.     ' Insert default drive if path begins with root backslash
  479.     '-------------------------------------------------------
  480.     If Left$(DestPath$, 1) = "\" Then
  481.     DestPath$ = DefaultDrive + DestPath$
  482.     End If
  483.     
  484.     '-----------------------------
  485.     ' check for invalid characters
  486.     '-----------------------------
  487.     On Error Resume Next
  488.     tmp$ = Dir$(DestPath$)
  489.     If Err <> 0 Then
  490.     GoTo parseErr
  491.     End If
  492.     
  493.  
  494.     '-----------------------------------------
  495.     ' Check for wildcard characters and spaces
  496.     '-----------------------------------------
  497.     If (InStr(DestPath$, "*") <> 0) GoTo parseErr
  498.     If (InStr(DestPath$, "?") <> 0) GoTo parseErr
  499.     If (InStr(DestPath$, " ") <> 0) GoTo parseErr
  500.      
  501.     
  502.     '------------------------------------------
  503.     ' Make Sure colon is in second char position
  504.     '------------------------------------------
  505.     If Mid$(DestPath$, 2, 1) <> Chr$(58) Then GoTo parseErr
  506.     
  507.  
  508.     '-------------------------------
  509.     ' Insert root backslash if needed
  510.     '-------------------------------
  511.     If Len(DestPath$) > 2 Then
  512.       If Right$(Left$(DestPath$, 3), 1) <> "\" Then
  513.     DestPath$ = Left$(DestPath$, 2) + "\" + Right$(DestPath$, Len(DestPath$) - 2)
  514.       End If
  515.     End If
  516.  
  517.     '-------------------------
  518.     ' Check drive to install on
  519.     '-------------------------
  520.     drive$ = Left$(DestPath$, 1)
  521.     ChDrive (drive$)                                                        ' Try to change to the dest drive
  522.     If Err <> 0 Then GoTo parseErr
  523.     
  524.     '-----------
  525.     ' Add final \
  526.     '-----------
  527.     If Right$(DestPath$, 1) <> "\" Then
  528.     DestPath$ = DestPath$ + "\"
  529.     End If
  530.     
  531.  
  532.     '-------------------------------------
  533.     ' Root dir is a valid dir
  534.     '-------------------------------------
  535.     If Len(DestPath$) = 3 Then
  536.     If Right$(DestPath$, 2) = ":\" Then
  537.         GoTo ParseOK
  538.     End If
  539.     End If
  540.     
  541.  
  542.     '------------------------
  543.     ' Check for repeated Slash
  544.     '------------------------
  545.     If InStr(DestPath$, "\\") <> 0 Then GoTo parseErr
  546.     
  547.     '--------------------------------------
  548.     ' Check for illegal directory names
  549.     '--------------------------------------
  550.     legalChar$ = "!#$%&'()-0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`{}~.ⁿΣ÷─╓▄▀"
  551.     BackPos = 3
  552.     forePos = InStr(4, DestPath$, "\")
  553.     Do
  554.     temp$ = Mid$(DestPath$, BackPos + 1, forePos - BackPos - 1)
  555.     
  556.     '----------------------------
  557.     ' Test for illegal characters
  558.     '----------------------------
  559.     For i = 1 To Len(temp$)
  560.         If InStr(legalChar$, UCase$(Mid$(temp$, i, 1))) = 0 Then GoTo parseErr
  561.     Next i
  562.  
  563.     '-------------------------------------------
  564.     ' Check combinations of periods and lengths
  565.     '-------------------------------------------
  566.     periodPos = InStr(temp$, ".")
  567.     length = Len(temp$)
  568.     If periodPos = 0 Then
  569.         If length > 8 Then GoTo parseErr                         ' Base too long
  570.     Else
  571.         If periodPos > 9 Then GoTo parseErr                      ' Base too long
  572.         If length > periodPos + 3 Then GoTo parseErr             ' Extension too long
  573.         If InStr(periodPos + 1, temp$, ".") <> 0 Then GoTo parseErr' Two periods not allowed
  574.     End If
  575.  
  576.     BackPos = forePos
  577.     forePos = InStr(BackPos + 1, DestPath$, "\")
  578.     Loop Until forePos = 0
  579.  
  580. ParseOK:
  581.     isvalidPath = True
  582.     Exit Function
  583.  
  584. parseErr:
  585.     isvalidPath = False
  586. End Function
  587.  
  588. Function PegaData (filename)
  589.     PegaData = FileDateTime(filename)
  590. End Function
  591.  
  592. Function PegaTamanho (filename)
  593.     PegaTamanho = FileLen(filename)
  594. End Function
  595.  
  596. '----------------------------------------------------
  597. ' Prompt for the next disk.  Use the FileToLookFor$
  598. ' argument to verify that the proper disk, disk number
  599. ' wDiskNum, was inserted.
  600. '----------------------------------------------------
  601. Function PromptForNextDisk (wDiskNum As Integer, FileToLookFor$) As Integer
  602.  
  603.     '-------------------------
  604.     ' Test for file
  605.     '-------------------------
  606.     Ready = False
  607.     On Error Resume Next
  608.     temp$ = Dir$(FileToLookFor$)
  609.  
  610.     '------------------------
  611.     ' If not found, start loop
  612.     '------------------------
  613.     If Err <> 0 Or Len(temp$) = 0 Then
  614.     While Not Ready
  615.         Err = 0
  616.         '----------------------------
  617.         ' Put up msg box
  618.         '----------------------------
  619.         Beep
  620.         x = MsgBox("Please insert disk # " + Format$(wDiskNum%), 49, "SETUP")
  621.         If x = 2 Then
  622.         '-------------------------------
  623.         ' Use hit cancel, abort the copy
  624.         '-------------------------------
  625.         PromptForNextDisk = False
  626.         GoTo ExitProc
  627.         Else
  628.         '----------------------------------------
  629.         ' User hits OK, try to find the file again
  630.         '----------------------------------------
  631.         temp$ = Dir$(FileToLookFor$)
  632.         If Err = 0 And Len(temp$) <> 0 Then
  633.             PromptForNextDisk = True
  634.             Ready = True
  635.         End If
  636.         End If
  637.     Wend
  638.     Else
  639.     PromptForNextDisk = True
  640.     End If
  641.  
  642.     
  643.  
  644. ExitProc:
  645.  
  646. End Function
  647.  
  648. Sub updatestatus (FileBytes As Long)
  649. '-----------------------------------------------------------------------------
  650. ' Update the status bar using form.control Statusdlg.Picture2
  651. '-----------------------------------------------------------------------------
  652.     
  653.     Dim estTotal As Long
  654.  
  655.     estTotal = Val(Statusdlg.total.Tag)
  656.     If estTotal = False Then
  657.     estTotal = 10000000
  658.     End If
  659.  
  660.     position = position + CSng((FileBytes / estTotal) * 100)
  661.     If position > 100 Then
  662.     position = 100
  663.     End If
  664.     Statusdlg.Picture2.Cls
  665.     Statusdlg.Picture2.Line (0, 0)-((position * (Statusdlg.Picture2.ScaleWidth / 100)), Statusdlg.Picture2.ScaleHeight), QBColor(10), BF
  666.  
  667.     Txt$ = Format$(CLng(position)) + "%"
  668.     Statusdlg.Picture2.CurrentX = (Statusdlg.Picture2.ScaleWidth - Statusdlg.Picture2.TextWidth(Txt$)) \ 2
  669.     Statusdlg.Picture2.CurrentY = (Statusdlg.Picture2.ScaleHeight - Statusdlg.Picture2.TextHeight(Txt$)) \ 2
  670.     Statusdlg.Picture2.Print Txt$
  671.  
  672.     r = BitBlt(Statusdlg.Picture1.hDC, 0, 0, Statusdlg.Picture2.ScaleWidth, Statusdlg.Picture2.ScaleHeight, Statusdlg.Picture2.hDC, 0, 0, SRCCOPY)
  673.  
  674. End Sub
  675.  
  676.