home *** CD-ROM | disk | FTP | other *** search
/ The Photo Companion / PCD1501 (Track 1).bin / merged.iso / setup / setup.mst < prev    next >
Encoding:
Text File  |  1996-03-07  |  22.6 KB  |  655 lines

  1. '**************************************************************************
  2. '*
  3. '*                      EasyPhoto 2.0 setup script
  4. '*                      based on MSSetup Toolkit Sample 2
  5. '*
  6. '**************************************************************************
  7. '*'$DEFINE DEBUG                    '* Used for Debugging messages
  8. '*COMMAND$ = "/S D:\EZPHOTO_\"      '* For running in Test Environment
  9.  
  10. '* Set up resuming of errors
  11. GLOBAL RESUME_ON_ERROR%
  12. GLOBAL ERR_RESUME%
  13. RESUME_ON_ERROR% = 0
  14. ERR_RESUME% = 0
  15.  
  16. '$INCLUDE 'setupapi.inc'
  17. '$INCLUDE 'msdetect.inc'
  18.  
  19. '* Subroutine declaration
  20. DECLARE SUB Initialize
  21. DECLARE SUB EasyInstall
  22. DECLARE SUB DoInstall
  23. DECLARE SUB DoUninstall
  24. DECLARE SUB DoQuit
  25. DECLARE SUB QueryQuit
  26. DECLARE FUNCTION InfoDialog( dialogID%) AS STRING
  27. DECLARE SUB CalculateTotalNeeds
  28. DECLARE SUB CalculateExistingPath
  29. DECLARE FUNCTION NeedsWillFit AS INTEGER
  30. DECLARE SUB AddSectionFilesToDeleteList( list$, section$, path$)
  31. DECLARE FUNCTION MakePath ( szDir$, szFile$) AS STRING
  32. DECLARE FUNCTION ShowWindow LIB "user" ( hwnd%, nCmdShow%) AS INTEGER
  33. DECLARE FUNCTION SetWindowPos LIB "user" ( hwnd%, hwndInsertAfter%, x%, y%, cx%, cy%, fuFlags%) AS INTEGER
  34. DECLARE FUNCTION DeleteDirectory LIB "mscuistf.dll" ( dirStr$) AS INTEGER
  35. DECLARE FUNCTION GetModuleHandle LIB "kernel" ( modName$) AS INTEGER
  36. DECLARE FUNCTION ExitWindowsExec LIB "user" ( exec$, param$) AS INTEGER
  37. DECLARE FUNCTION WinExec LIB "kernel" ( cmdLine$, nCmdShow%) AS INTEGER
  38. DECLARE SUB UpdateRegFile
  39.  
  40. '* Dialog IDs
  41. CONST DLG_EASYINSTALL = 11000
  42. CONST DLG_INFO_TOOBIG = 13001
  43. CONST DLG_INFO_BADPATH = 13002
  44. CONST DLG_INFO_ASKQUIT = 13003
  45. CONST DLG_INFO_EXITOK = 13004
  46. CONST DLG_INFO_EXITQUIT = 13005
  47. CONST DLG_INFO_EXITFAIL = 13006
  48. CONST DLG_INFO_UNINSTALLOK = 13007
  49. CONST DLG_INFO_BADVERSION = 13008
  50. CONST DLG_INFO_NORESTART = 13009
  51. CONST DLG_INFO_NEEDRESTART = 13010
  52. CONST DLG_INFO_EPRUNNING = 13011
  53. CONST DLG_INFO_NOPROGGRP = 13015
  54. CONST DLG_INFO_HANDLER = 13016
  55. CONST DLG_PMCOMMAND = 14000
  56. CONST DLG_INFO_BADPROCESSOR = 14001
  57.  
  58. '* Error code
  59. CONST UNINSTALL_COMPLETE = 10000
  60.  
  61. '* Global for Custom User Interface DLL
  62. GLOBAL CUIDLL$
  63.  
  64. '* Some Global strings.
  65. GLOBAL NEEDS_TOTAL$
  66. GLOBAL WINDOWSEXTRAS$
  67. GLOBAL EXISTPATH$
  68. GLOBAL DEST$
  69. GLOBAL WINWORD$
  70. GLOBAL SOURCEPATH$
  71.  
  72. MAIN:
  73.      '* Initialize
  74.     Initialize
  75.  
  76.     '* Do easy install
  77.     EasyInstall
  78.  
  79. QUIT:
  80.     '* If there is an error, but we are resuming, then set the ERR_RESUME flag and clear ERR flag
  81.     '* Then RESUME on the NEXT instruction
  82.     IF (( ERR <> 0) AND ( RESUME_ON_ERROR% = 1)) THEN
  83.         ERR_RESUME% = ERR
  84.         ERR = 0
  85.         RESUME NEXT
  86.     ENDIF
  87.  
  88.    '* Do normal quit
  89.      DoQuit
  90. END
  91.  
  92. '*******************************************************************************
  93. '* Initialize
  94. '*
  95. '* Perform necessary initializations
  96. '*******************************************************************************
  97. SUB Initialize STATIC
  98.  
  99.     '* Maximize the parent window
  100.     result% = ShowWindow( HwndFrame(), 3)      '* SW_SHOWMAXIMIZED
  101.     '* SWP_NOMOVE | SWP_NOSIZE
  102.     result% = SetWindowPos( HwndFrame(), -1, 0, 0, 0, 0, 3)
  103.  
  104.     '* Set up the custom UI and help dialog procedures
  105.     CUIDLL$ = "MSCUISTF.DLL"
  106.  
  107.     '* Initialize some strings
  108.     NEEDS_TOTAL$ = "TotalNeeds"
  109.     WINDOWSEXTRAS$ = "ExtraCosts"
  110.     EXISTPATH$ = "ExistingPath"
  111.  
  112.     '* Set the about box and main window title
  113.     SetAbout "EasyPhoto Setup", "Copyright (c) 1995 Storm Software"
  114.     SetTitle "EasyPhoto Installer"
  115.  
  116.     '* Determine the .INF file and read it in
  117.     infPath$ = GetSymbolValue( "STF_SRCINFPATH")
  118.     IF infPath$ = "" THEN
  119.     infPath$ = GetSymbolValue( "STF_CWDDIR") + "SETUP.INF"
  120.     ENDIF
  121.     ReadInfFile infPath$
  122.  
  123.     '* Determines if we have the correct windows version or not...
  124.     IF (( GetWindowsMajorVersion() < 3) OR (( GetWindowsMajorVersion = 3) AND ( GetWindowsMinorVersion < 1))) THEN
  125.     resultStr$ = InfoDialog( DLG_INFO_BADVERSION)
  126.     END
  127.     ENDIF
  128.  
  129.     '* If we are on less than a 80386 processor then quit
  130.     IF ( GetProcessorType < 3) THEN
  131.         resultStr$ = InfoDialog( DLG_INFO_BADPROCESSOR)
  132.     END
  133.     ENDIF
  134.  
  135.     '* Make sure handler is not active
  136.     IF ( GetModuleHandle( "HANDLER")) THEN
  137.         resultStr$ = InfoDialog( DLG_INFO_HANDLER)
  138.         END
  139.     ENDIF
  140.  
  141.     '* Make sure that EasyPhoto is not running now
  142.     IF ( GetModuleHandle( "EZPHOTO")) THEN
  143.         resultStr$ = InfoDialog( DLG_INFO_EPRUNNING)
  144.         END
  145.     ENDIF
  146.  
  147.     '* Determine the source path, ie. E:\SETUP
  148.     SOURCEPATH$ = GetSymbolValue( "STF_CWDDIR")
  149.     SOURCEPATH$ = MID$( SOURCEPATH$, 1, LEN( SOURCEPATH$) - 6)
  150.  
  151.      '* Calculate the existing path
  152.     CalculateExistingPath
  153.  
  154.     '* Determine default destination, which is either of
  155.     '* - Currently installed location
  156.     '* - Windows\EZPHOTO
  157.     winDrive$ = UCASE$( MID$( GetWindowsDir, 1, 1))
  158.     temp$ = GetSymbolValue( EXISTPATH$)
  159.     IF temp$ = "" THEN
  160.         DEST$ = winDrive$ + ":\EZPHOTO"
  161.     ELSE
  162.         IF ( MID$( temp$, LEN( temp$), 1) = "\") THEN
  163.             temp$ = MID$ ( temp$, 1, LEN( temp$) - 1)
  164.         ENDIF
  165.         DEST$ = temp$
  166.     ENDIF
  167.  
  168.     '* Determine the word for windows startup path
  169.     iniPath$ = FindFileInTree( "WINWORD6.INI", GetWindowsDir)
  170.     IF ( iniPath$ <> "") THEN
  171.         WINWORD$ = GetIniKeyString( iniPath$, "Microsoft Word", "STARTUP-PATH")
  172.         IF (DoesDirExist(WINWORD$) = 0) THEN
  173.             WINWORD$ = ""
  174.         ENDIF
  175.     ELSE
  176.         WINWORD$ = ""
  177.     ENDIF
  178.  
  179.     '* Set up the drive lists
  180.     FOR i% = 1 TO 26
  181.     AddListItem WINDOWSEXTRAS$, "0"
  182.     AddListItem NEEDS_TOTAL$, "0"
  183.     NEXT i%
  184.     ReplaceListItem WINDOWSEXTRAS$, ASC( winDrive$) - ASC( "A") + 1, "10240"
  185. END SUB
  186.  
  187. '*******************************************************************************
  188. '* EasyInstall
  189. '*
  190. '* The main loop to query the user about installation options
  191. '*******************************************************************************
  192. SUB EasyInstall STATIC
  193.  
  194.     '* Loop
  195.     WHILE 1
  196.  
  197.     '* Switch on the result of the primary dialog
  198.     SetSymbolValue "PathText", DEST$
  199.     SELECT CASE ( UIStartDlg( CUIDLL$, DLG_EASYINSTALL, "EasyInstallProc", 0, ""))
  200.  
  201.         '* Install was pressed, install only if each section fits
  202.         CASE "INSTALL"
  203.         newPath$ = GetSymbolValue( "PathText")
  204.         IF ( IsDirWritable( newPath$) = 1) THEN
  205.             DEST$ = newPath$
  206.             CalculateTotalNeeds
  207.             IF ( NeedsWillFit = 1) THEN
  208.             UIPop 1
  209.             DoInstall
  210.             EXIT WHILE
  211.             ELSE
  212.             result$ = InfoDialog( DLG_INFO_TOOBIG)
  213.             ENDIF
  214.         ELSE
  215.             result$ = InfoDialog( DLG_INFO_BADPATH)
  216.         ENDIF
  217.  
  218.         '* Do an install
  219.         CASE "UNINSTALL"
  220.         UIPop 1
  221.         DoUninstall
  222.         EXIT WHILE
  223.  
  224.         CASE "EXIT"
  225.         QueryQuit
  226.  
  227.         CASE "REACTIVATE"
  228.         CalculateExistingPath
  229.     END SELECT
  230.     WEND
  231. END SUB
  232.  
  233. '*******************************************************************************
  234. '* DoInstall
  235. '*
  236. '* Actually do the installation
  237. '*******************************************************************************
  238. SUB DoInstall STATIC
  239.  
  240.     '* Remove trailing \ in DEST$
  241.     IF ( MID$( DEST$, LEN( DEST$), 1) = "\") THEN
  242.     DEST$ = MID$ ( DEST$, 1, LEN( DEST$) - 1)
  243.     ENDIF
  244.  
  245.     '* Make sure that we have a place to copy the files to
  246.     CreateDir DEST$, cmoNone
  247.     CreateDir MakePath( DEST$, "GALLERY"), cmoNone
  248.     CreateDir MakePath( DEST$, "PHOTO"), cmoNone
  249.  
  250.     '* Sets the restart directory
  251.     SetRestartDir DEST$
  252.  
  253.     '* Actually copy the files
  254.     CopyFilesInCopyList
  255.  
  256.     '* Set the wait cursor and initialize
  257.     CursorSave% = ShowWaitCursor()
  258.  
  259.     '* Fix up the OLE reg file
  260.     UpdateRegFile
  261.  
  262.     '* Added mapping stuff
  263.     DstStr$ = MakePath( GetWindowsDir, "WIN.INI")
  264.     SetStr$ = MakePath( DEST$, "EZPHOTO.EXE") + " ^.GAL"
  265.     CreateIniKeyValue DstStr$, "Extensions", "GAL", SetStr$, cmoOverwrite
  266.  
  267.     '* add&we added 9/7/95 to install WEMU387.386
  268.     '* Create a duplicate of SYSTEM.INI called SYSTEM.GAL to tear apart for WEMU387.386
  269.     SrcStr$ = MakePath( GetWindowsDir, "SYSTEM.INI")
  270.     '* (we) I don't know why this needs to have a different extension
  271.     DstStr$ = MakePath( GetWindowsDir, "SYSTEM.GA2")
  272.     CopyFile SrcStr$, DstStr$, cmoOverWrite, 0
  273.  
  274.     '* Go through file looking for DEVICE=WEMU387.386 in [386Enh]
  275.     WHILE 1
  276.         result$ = GetIniKeyString( DstStr$, "386Enh", "DEVICE")
  277.  
  278.     '* If we found an existing one, then stop searching
  279.         IF ( UCASE$( result$) = "WEMU387.386") THEN
  280.              EXIT WHILE
  281.  
  282.     '* If there are no more DEVICE= then add it in the SYSTEM.INI
  283.         ELSEIF ( result$ = "") THEN
  284.             CreateSysIniKeyValue SrcStr$, "386Enh", "DEVICE", "WEMU387.386", cmoNone
  285.             EXIT WHILE
  286.  
  287.     '* Otherwise, remove this DEVICE= and go to the next one
  288.          ELSE
  289.              RemoveIniKey DstStr$, "386Enh", "DEVICE", cmoNone
  290.          ENDIF
  291.     WEND
  292.  
  293.     '* Remove the temporary file
  294.     RemoveFile DstStr$, cmoForce
  295.  
  296.     '* Add configuration info to EZPHOTO.INI
  297.     DstStr$ = MakePath( GetWindowsDir, "EZPHOTO.INI")
  298.     SetStr$ = DEST$ + "\"
  299.     CreateIniKeyValue DstStr$, "EasyPhoto Directories", "AppRoot", SetStr$, cmoOverwrite
  300.     CreateIniKeyValue DstStr$, "EasyPhoto Directories", "Template", SetStr$, cmoOverwrite
  301.     SetStr$ = MakePath( DEST$, "GALLERY\")
  302.     CreateIniKeyValue DstStr$, "EasyPhoto Directories", "Gallery", SetStr$, cmoOverwrite
  303.     SetStr$ = MakePath( DEST$, "PHOTO\")
  304.     CreateIniKeyValue DstStr$, "EasyPhoto Directories", "Photo", SetStr$, cmoOverwrite
  305.     CreateIniKeyValue DstStr$, "Warning Max", "Max", "1", cmoOverwrite
  306.     CreateIniKeyValue DstStr$, "Warning Max", "Current Count", "0", cmoOverwrite
  307.  
  308.    '* This next section can be resumed on an error
  309.     RESUME_ON_ERROR% = 1
  310.     ERR_RESUME% = 0
  311.  
  312.     '* Attempt to create a program manager group
  313.     oldMode% = SetSilentMode( 1)
  314.     CreateProgmanGroup "EasyPhoto", "", cmoVital
  315.     ShowProgmanGroup "EasyPhoto", 1, cmoVital
  316.     oldMode% = SetSilentMode( oldMode%)
  317.  
  318.     '* We don't want to resume on error any more
  319.     RESUME_ON_ERROR% = 0
  320.  
  321.     '* Set cursor back
  322.     RestoreCursor CursorSave%
  323.  
  324.     '* Check to see if the program manager group was created, if so create items.
  325.     IF ( ERR_RESUME% = 0) THEN
  326.     CreateProgmanItem "EasyPhoto", "Welcome to EasyPhoto!", MakePath( SOURCEPATH$, "DEMO\EZ2DEMO.EXE"), "", cmoOverwrite
  327.     CreateProgmanItem "EasyPhoto", "Read Me!", "WRITE.EXE " + MakePath( DEST$, "EZ2READ.WRI"), "", cmoOverwrite
  328.     '*CreateProgmanItem "EasyPhoto", "EasyPhoto" + CHR$(13) + "Try Me!", MakePath( DEST$, "EZPHOTO.EXE"), "", cmoOverwrite
  329.     CreateProgmanItem "EasyPhoto", "EasyPhoto Try Me!", MakePath( DEST$, "EZPHOTO.EXE"), "", cmoOverwrite
  330.  
  331.     '* Otherwise, post a message about the failure to create the group.
  332.     ELSE
  333.        result$ = InfoDialog( DLG_INFO_NOPROGGRP)
  334.     ENDIF
  335.  
  336.     '* If the restart list is not empty then do a restart
  337.     IF ( RestartListEmpty = 0) THEN
  338.         result$ = InfoDialog( DLG_INFO_NEEDRESTART)
  339.     WHILE 1
  340.         '* Remove the window's ONTOP attribute
  341.         winresult% = SetWindowPos( HwndFrame(), -2, 0, 0, 0, 0, 3)
  342.         resultNum% = ExitExecRestart
  343.  
  344.         '* user needs to get a chance to
  345.         '* manually quit the applications that are still alive (DOS Boxes).
  346.         IF ( InfoDialog( DLG_INFO_NORESTART) <> "OK") THEN
  347.         EXIT WHILE
  348.         ENDIF
  349.     WEND
  350.     ERROR STFERR
  351.     ENDIF
  352.  
  353. END SUB
  354.  
  355. '*******************************************************************************
  356. '* DoUninstall
  357. '*
  358. '* Actually do the un-installation
  359. '*******************************************************************************
  360. SUB DoUninstall STATIC
  361.  
  362.     '* Set the wait cursor and initialize
  363.     CursorSave% = ShowWaitCursor()
  364.  
  365.     '* Recalculate the existing path one last time, exit if does not exist.
  366.     CalculateExistingPath
  367.     DstStr$ = GetSymbolValue( EXISTPATH$)
  368.  
  369.     '* If we have an existing path, then delete everything
  370.     IF ( DstStr$ <> "") THEN
  371.  
  372.     '* Remove trailing \ in DstStr$
  373.     IF ( MID$( DstStr$, LEN( DstStr$), 1) = "\") THEN
  374.         DstStr$ = MID$ ( DstStr$, 1, LEN( DstStr$) - 1)
  375.     ENDIF
  376.  
  377.     '* Make a list from the file names from each section
  378.     AddSectionFilesToDeleteList "DeleteList", "EZ_MAIN", DstStr$
  379.     AddSectionFilesToDeleteList "DeleteList", "EZ_WIN", GetWindowsDir
  380.     AddSectionFilesToDeleteList "DeleteList", "EZ_SYS", GetWindowsSysDir
  381.     '* AddSectionFilesToDeleteList "DeleteList", "EZ_TWAIN", MakePath( GetWindowsDir, "TWAIN\PHOTO\")
  382.     AddSectionFilesToDeleteList "DeleteList", "GALLERY", MakePath( DstStr$, "GALLERY")
  383.     IF ( WINWORD$ <> "") THEN
  384.         AddSectionFilesToDeleteList "DeleteList", "EZ_MS", WINWORD$
  385.     ENDIF
  386.  
  387.     '* Add EZPHOTO.INI in windows directory
  388.     AddListItem "DeleteList", MakePath( GetWindowsDir, "EZPHOTO.INI")
  389.  
  390.     '* Loop through those files and delete them all, if they truly exist
  391.     FOR i% = 1 TO GetListLength( "DeleteList")
  392.         fileStr$ = GetListItem( "DeleteList", i%)
  393.         IF ( DoesFileExist( fileStr$, femExists) = 1) THEN
  394.         RemoveFile fileStr$, cmoForce
  395.         ENDIF
  396.     NEXT i%
  397.  
  398.     '* Remove all of the directories, if possible...
  399.     deleteResult% = DeleteDirectory( MakePath( DstStr$, "GALLERY"))
  400.     deleteResult% = DeleteDirectory( MakePath( DstStr$, "PHOTO"))
  401.     deleteResult% = DeleteDirectory( DstStr$)
  402.     deleteResult% = DeleteDirectory( MakePath( GetWindowsDir, "TWAIN\PHOTO"))
  403.     deleteResult% = DeleteDirectory( MakePath( GetWindowsDir, "TWAIN"))
  404.  
  405.     '* Create a duplicate of SYSTEM.INI called SYSTEM.GAL to tear apart for VPPSD.386
  406.     SrcStr$ = MakePath( GetWindowsDir, "SYSTEM.INI")
  407.     DstStr$ = MakePath( GetWindowsDir, "SYSTEM.GAL")
  408.     CopyFile SrcStr$, DstStr$, cmoOverWrite, 0
  409.  
  410.     '* Remove program group from program manager
  411.     SetSymbolValue "ProgmanCommand", "[DeleteGroup(EasyPhoto)]"
  412.     result$ = UIStartDlg( CUIDLL$, DLG_PMCOMMAND, "SendProgmanProc", 0, "")
  413.     UIPop 1
  414.  
  415.     '* Remove mapping stuff
  416.     DstStr$ = MakePath( GetWindowsDir, "WIN.INI")
  417.     RemoveIniKey DstStr$, "Extensions", "GAL", cmoNone
  418.  
  419.     ENDIF
  420.  
  421.     '* Set cursor back
  422.     RestoreCursor CursorSave%
  423.  
  424.     ERR = UNINSTALL_COMPLETE
  425. END SUB
  426.  
  427. '*******************************************************************************
  428. '* DoQuit
  429. '*
  430. '* Quit.
  431. '*******************************************************************************
  432. SUB DoQuit STATIC
  433.  
  434.     restart%=0
  435.     '* Which dialog should we use depends upon the ERR code
  436.     IF ERR = 0 THEN
  437.     dlg% = DLG_INFO_NEEDRESTART '* was: DLG_INFO_EXITOK
  438.     restart% = 1
  439.     ELSEIF ERR = STFQUIT THEN
  440.     dlg% = DLG_INFO_EXITQUIT
  441.     ELSEIF ERR = UNINSTALL_COMPLETE THEN
  442.     dlg% = DLG_INFO_UNINSTALLOK
  443.     ELSE
  444.     dlg% = DLG_INFO_EXITFAIL
  445.     END IF
  446.  
  447.     '* Do the dialog, then kill it and end.
  448.     result$ = UIStartDlg(CUIDLL$, dlg%, "InformationProc", 0, "")
  449.     UIPop 1
  450.  
  451.     IF restart%=1 THEN
  452.     '* Now we are ready to restart windows. Do this in a loop so
  453.     '* that if the restart fails (because of open applications),
  454.     '* we can tell the user what to do and try again.
  455.     WHILE 1
  456.          '*remove windows ON TOP attribute
  457.          winresult% = SetWindowPos( HwndFrame(), -2, 0, 0, 0, 0, 3)
  458.          exec$ = MakePath( DEST$, "_msrstrt.exe")
  459.          monkey% = ExitWindowsExec( exec$, "")
  460.  
  461.         '* user needs to get a chance to manually quit the
  462.         '*applications that are still alive (DOS Boxes).
  463.         IF ( InfoDialog( DLG_INFO_NORESTART) <> "OK") THEN
  464.         EXIT WHILE
  465.         ENDIF
  466.     WEND
  467.     ENDIF
  468.  
  469.     '* Exit the application
  470.     END
  471. END SUB
  472.  
  473. '*******************************************************************************
  474. '* QueryQuit
  475. '*
  476. '* Popup the dialog to tell the user that they have selected an invalid path.
  477. '*******************************************************************************
  478. SUB QueryQuit STATIC
  479.  
  480.     '* Does the user want to quit?
  481.     IF ( InfoDialog( DLG_INFO_ASKQUIT) = "EXIT") THEN
  482.     END
  483.     ENDIF
  484. END SUB
  485.  
  486. '*******************************************************************************
  487. '* InfoDialog
  488. '*
  489. '* Generic information dialog, returns result of dialog as a string.
  490. '*******************************************************************************
  491. FUNCTION InfoDialog( dialogID%) STATIC AS STRING
  492.  
  493.     '* Do the Dialog, then kill it.
  494.     InfoDialog = UIStartDlg( CUIDLL$, dialogID, "InformationProc", 0, "")
  495.     UIPop 1
  496. END FUNCTION
  497.  
  498. '*******************************************************************************
  499. '* CalculateTotalNeeds
  500. '*
  501. '* Calculates the total needs for the install
  502. '*******************************************************************************
  503. SUB CalculateTotalNeeds STATIC
  504.  
  505.     '* Set the wait cursor and initialize
  506.     CursorSave% = ShowWaitCursor()
  507.  
  508.     '* Clear the copy list
  509.     ClearCopyList
  510.  
  511.     '* Add the EZPhoto files to the copy list
  512.     SrcDir$ = MakePath( GetSymbolValue( "STF_SRCDIR"), "EZPHOTO")
  513.     AddSectionFilesToCopyList "EZ_MAIN", SrcDir$, DEST$
  514.     AddSectionFilesToCopyList "EZ_WIN", SrcDir$, GetWindowsDir
  515.     AddSectionFilesToCopyList "EZ_WINTW", SrcDir$, GetWindowsDir
  516.     AddSectionFilesToCopyList "EZ_SYS", SrcDir$, GetWindowsSysDir
  517.     AddSectionFilesToCopyList "EZ_SYSEMU", SrcDir$, GetWindowsSysDir
  518.     '* AddSectionFilesToCopyList "EZ_TWAIN", SrcDir$, MakePath( GetWindowsDir, "TWAIN\PHOTO\")
  519.     IF ( WINWORD$ <> "") THEN
  520.     AddSectionFilesToCopyList "EZ_MS", SrcDir$, WINWORD$
  521.     ENDIF
  522.  
  523.     '* Add the OLE2 files to the copy list
  524.     SrcDir$ = MakePath( GetSymbolValue( "STF_SRCDIR"), "OLE2")
  525.     AddSectionFilesToCopyList "OLE2_SYS", SrcDir$, GetWindowsSysDir
  526.  
  527.     '* Add the Gallery files to the copy list
  528.     SrcDir$ = MakePath( GetSymbolValue( "STF_SRCDIR"), "GALLERY")
  529.     AddSectionFilesToCopyList "GALLERY", SrcDir$, MakePath( DEST$, "GALLERY")
  530.  
  531.     '* Add the photo files to the copy list
  532.     SrcDir$ = MakePath( GetSymbolValue( "STF_SRCDIR"), "PHOTO")
  533.     AddSectionFilesToCopyList "PHOTO", SrcDir$, MakePath( DEST$, "PHOTO")
  534.  
  535.     '* Actually determine how much each list costs
  536.     extra% = GetCopyListCost( WINDOWSEXTRAS$, NEEDS_TOTAL$, "")
  537.  
  538.     '* Restore the cursor back to original
  539.     RestoreCursor CursorSave%
  540. END SUB
  541.  
  542. '*******************************************************************************
  543. '* NeedsWillFit
  544. '*
  545. '* Recalculates disk space and returns if the files will fit each drive or not.
  546. '*******************************************************************************
  547. FUNCTION NeedsWillFit STATIC AS INTEGER
  548.  
  549.     '* Set wait cursor
  550.     CursorSave% = ShowWaitCursor()
  551.  
  552.     '* Initialize
  553.     NeedsWillFit = 1
  554.  
  555.     '* Go through each of the drives and check each drive
  556.     FOR drive% = 1 TO 26
  557.         needSpace& = VAL( GetListItem( NEEDS_TOTAL$, drive%))
  558.         IF ( needSpace& > 0 ) THEN
  559.             freeSpace& = GetFreeSpaceForDrive( CHR$( ASC( "A") + drive% - 1))
  560.             IF ( freeSpace& < needSpace&) THEN
  561.                 NeedsWillFit = 0
  562.                 EXIT FOR
  563.             ENDIF
  564.         ENDIF
  565.     NEXT drive%
  566.  
  567.     '* Set cursor back
  568.     RestoreCursor CursorSave%
  569. END FUNCTION
  570.  
  571. '*******************************************************************************
  572. '* CalculateExistingPath
  573. '*
  574. '* Calculates the existing path to a current installation
  575. '*******************************************************************************
  576. SUB CalculateExistingPath STATIC
  577.  
  578.     '* Locate the EZPHOTO.INI file and APPROOT Path...
  579.     DstStr$ = MakePath( GetWindowsDir, "EZPHOTO.INI")
  580.     result$ = GetIniKeyString( DstStr$, "EasyPhoto Directories", "AppRoot")
  581.     SetSymbolValue EXISTPATH$, result$
  582. END SUB
  583.  
  584. '*******************************************************************************
  585. '* AddSectionFilesToDeleteList
  586. '*
  587. '* Will add a bunch of files with a path to a final list
  588. '*******************************************************************************
  589. SUB AddSectionFilesToDeleteList( list$, section$, path$) STATIC
  590.  
  591.     '* Make a temporary list from the files in the particular section
  592.     MakeListFromSectionFilename "TempList", section$
  593.  
  594.     '* Go through temporary list, adds appropriate path, then to final list
  595.     FOR i% = 1 TO GetListLength( "TempList")
  596.     fileStr$ = GetListItem( "TempList", i%)
  597.     AddListItem list$, MakePath( path$, fileStr$)
  598.     NEXT i%
  599. END SUB
  600.  
  601. '*******************************************************************************
  602. '* MakePath
  603. '*
  604. '* Appends a file name to the end of a directory path,
  605. '* inserting a backslash character as needed.
  606. '*******************************************************************************
  607. FUNCTION MakePath ( szDir$, szFile$) STATIC AS STRING
  608.  
  609.     '* No directory, so just the file
  610.     IF szDir$ = "" THEN
  611.     MakePath = szFile$
  612.  
  613.     '* No file, so just the directory
  614.     ELSEIF szFile$ = "" THEN
  615.     MakePath = szDir$
  616.  
  617.     '* Add the two together, no slash necessary
  618.     ELSEIF MID$( szDir$, LEN( szDir$), 1) = "\" THEN
  619.     MakePath = szDir$ + szFile$
  620.  
  621.     '* Add the two together, a slash is necessary
  622.     ELSE
  623.     MakePath = szDir$ + "\" + szFile$
  624.     END IF
  625. END FUNCTION
  626.  
  627. '*******************************************************************************
  628. '* UpdateRegFile
  629. '*
  630. '* Fix the OLE reg file to point to the installed EZPHOTO stuff.
  631. '*******************************************************************************
  632. SUB UpdateRegFile STATIC
  633.     regfile$ = MakePath(DEST$, "EZPHOTO.REG")
  634.     open regfile$ for append as #1
  635.  
  636.     print #1, "HKEY_CLASSES_ROOT\CLSID\{0002C800-0000-0000-C000-000000000046}\DefaultIcon = " + MakePath(DEST$, "EZPHOTO.EXE") + ",0"
  637.     print #1, "HKEY_CLASSES_ROOT\CLSID\{0002C800-0000-0000-C000-000000000046}\InprocHandler = " + MakePath(DEST$, "HANDLER.DLL")
  638.     print #1, "HKEY_CLASSES_ROOT\CLSID\{0002C800-0000-0000-C000-000000000046}\InprocServer32 = " + MakePath(DEST$, "HANDL32.DLL")
  639.     print #1, "HKEY_CLASSES_ROOT\CLSID\{0002C800-0000-0000-C000-000000000046}\LocalServer = " + MakePath(DEST$, "EZPHOTO.EXE")
  640.     print #1, "HKEY_CLASSES_ROOT\EasyPhoto.Photograph\protocol\StdFileEditing\server = " + MakePath(DEST$, "EZPHOTO.EXE")
  641.     print #1, "HKEY_CLASSES_ROOT\EasyPhoto.Photograph\shell\open\command = " + MakePath(DEST$, "EZPHOTO.EXE") + " %1"
  642.     print #1, "HKEY_CLASSES_ROOT\EasyPhoto.Gallery\shell\open\command = " + MakePath(DEST$, "EZPHOTO.EXE") + " %1"
  643.  
  644.     close #1
  645.  
  646.     cmdLine$ = "REGEDIT /S " + regfile$
  647.     monkey% = WinExec(cmdLine$, 0)  '* 0 == SW_HIDE, to hide the window.
  648.  
  649.     '* Insert OLE stuff into the registration database.
  650.     cmdLine$ = "REGEDIT /S " + GetWindowsSysDir + "OLE2.REG"
  651.     monkey% = WinExec(cmdLine$, 0)  '* 0 == SW_HIDE, to hide the window.
  652.  
  653. END SUB
  654.  
  655.