home *** CD-ROM | disk | FTP | other *** search
/ MIDI Music Collection / MUSIC.iso / cakewalk.30 / disk1 / wincake.ms_ / wincake.bin
Encoding:
Text File  |  1994-05-08  |  20.3 KB  |  632 lines

  1. '**************************************************************************
  2. '* $Header:   G:/SRC/WCW/MSSETUP/VCS/WINCAKE.MSV   1.27   09 May 1994 13:19:02   GH  $
  3. '*
  4. '* DESCRIPTION: MS-Setup script for Wincake and Wcwdemo.
  5. '*
  6. '* $Log:   G:/SRC/WCW/MSSETUP/VCS/WINCAKE.MSV  $
  7. '* 
  8. '*    Rev 1.27   09 May 1994 13:19:02   GH
  9. '* Detect/require 80386 or higher, warn about no mouse.
  10. '* 
  11. '*    Rev 1.26   28 Apr 1994 21:26:02   GH
  12. '* Use SRC.INS and MASTER.INS
  13. '* 
  14. '*    Rev 1.25   25 Apr 1994 13:40:06   GH
  15. '* For CPW, changed DEST$ to C:\CPW30
  16. '* 
  17. '*    Rev 1.24   15 Apr 1994 15:34:48   GH
  18. '* Changes for 2.5 Beta
  19. '* 
  20. '*    Rev 1.23   17 Feb 1994 13:17:14   PS
  21. '* Associate .TPL files with us, too.
  22. '* 
  23. '*    Rev 1.22   11 Jan 1994 13:47:38   CP
  24. '* Create a Home Studio Demo version.
  25. '* 
  26. '*    Rev 1.21   08 Nov 1993 15:41:42   CP
  27. '* Change Lite name from WCWLITE to CAKEHS.
  28. '* 
  29. '*    Rev 1.20   23 Aug 1993 14:06:06   CP
  30. '* Default installation directory for Demo is now C:\WCWDEMO to prevent
  31. '* nuking of previous installations.
  32. '* 
  33. '*    Rev 1.19   24 May 1993 17:09:22   gwh
  34. '* Removed serial number item from user info prompt.
  35. '* 
  36. '*    Rev 1.18   18 Apr 1993 17:50:40   gwh
  37. '* More refinements for user name, organization, serial number stamping.
  38. '* 
  39. '*    Rev 1.17   01 Apr 1993 18:32:44   gwh
  40. '* Prompt user for Name, Organization, and Serial number.
  41. '* Stamp the .EXE resources for these items.
  42. '* 
  43. '*    Rev 1.16   18 Mar 1993 14:06:42   pws
  44. '* No more need to clean up old DLL's in Windows sys dir (or TTSSEQ.INI).
  45. '* Also check for existence of TTSSEQ.INI in install dir before copying
  46. '* any TTSSEQ.INI found in Windows sys dir before copying new files.
  47. '* 
  48. '*    Rev 1.15   05 Mar 1993 12:08:38   pws
  49. '* Fix support for multiple-disk installations, which had broken when
  50. '* we started determining which product we were by testing for the
  51. '* existence of name.EXE on the first diskette but it had been put
  52. '* on the second one.  Now determine which product we are by testing
  53. '* for existence of product-specific section in SETUP.INF file.
  54. '* 
  55. '*    Rev 1.14   22 Dec 1992 13:17:36   pws
  56. '* Reflect changed dialog id's in BLDCUI\DIALOGS.H.
  57. '* 
  58. '*    Rev 1.13   15 Dec 1992 14:47:18   pws
  59. '* Added CTL3D.DLL.
  60. '* 
  61. '*    Rev 1.12   10 Nov 1992 12:37:56   pws
  62. '* Made more dialogs product-specific.
  63. '* 
  64. '* ---
  65. '* See logfile for earlier revision comments
  66. '*
  67. '* Copyright (C) 1990- by Greg Hendershott.  All rights reserved.
  68. '**************************************************************************
  69.  
  70. '$INCLUDE 'setupapi.inc'
  71. '$INCLUDE 'msdetect.inc'
  72. '$INCLUDE 'msregdb.inc'
  73.  
  74. ''These should have all been in SETUPAPI.INC.
  75. ''Note that duplicate definitions are errors and so are commented out!
  76.  
  77. 'CONST MB_OK               = &H0000
  78. CONST MB_OKCANCEL         = &H0001
  79. CONST MB_ABORTRETRYIGNORE = &H0002
  80. CONST MB_YESNOCANCEL      = &H0003
  81. CONST MB_YESNO            = &H0004
  82. CONST MB_RETRYCANCEL      = &H0005
  83. CONST MB_TYPEMASK         = &H000F
  84.  
  85. 'CONST MB_ICONHAND         = &H0010
  86. CONST MB_ICONQUESTION     = &H0020
  87. CONST MB_ICONEXCLAMATION  = &H0030
  88. CONST MB_ICONASTERISK     = &H0040
  89. CONST MB_ICONMASK         = &H00F0
  90.  
  91. CONST MB_ICONINFORMATION  = MB_ICONASTERISK
  92. CONST MB_ICONSTOP         = MB_ICONHAND
  93.  
  94. CONST MB_DEFBUTTON1       = &H0000
  95. CONST MB_DEFBUTTON2       = &H0100
  96. CONST MB_DEFBUTTON3       = &H0200
  97. CONST MB_DEFMASK          = &H0F00
  98.  
  99. CONST MB_APPLMODAL        = &H0000
  100. CONST MB_SYSTEMMODAL      = &H1000
  101. 'CONST MB_TASKMODAL        = &H2000
  102.  
  103. CONST MB_NOFOCUS          = &H8000
  104.  
  105. CONST IDOK                = 1
  106. CONST IDCANCEL            = 2
  107. CONST IDABORT             = 3
  108. CONST IDRETRY             = 4
  109. CONST IDIGNORE            = 5
  110. CONST IDYES               = 6
  111. CONST IDNO                = 7
  112.  
  113. ''Dialog ID's
  114. CONST WELCOME_PRO             = 170
  115. CONST WELCOME_DEMO            = 171
  116. CONST WELCOME_LITE            = 172
  117. CONST WELCOME_LITEDEMO        = 173
  118. CONST ASKQUIT                 = 200
  119. CONST DESTPATH                = 300
  120. CONST USERINFO                  = 310
  121. CONST EXITFAILURE             = 400
  122. CONST EXITQUIT_PRO            = 670
  123. CONST EXITQUIT_DEMO           = 671
  124. CONST EXITQUIT_LITE           = 672
  125. CONST EXITQUIT_LITEDEMO       = 673
  126. CONST EXITSUCCESS_PRO         = 770
  127. CONST EXITSUCCESS_DEMO        = 771
  128. CONST EXITSUCCESS_LITE        = 772
  129. CONST EXITSUCCESS_LITEDEMO    = 773
  130. CONST APPHELP_PRO             = 970
  131. CONST APPHELP_DEMO            = 971
  132. CONST APPHELP_LITE            = 972
  133. CONST APPHELP_LITEDEMO        = 973
  134. CONST INI_NOT_OVERWRITTEN     = 1000
  135. CONST PATCHES_NOT_OVERWRITTEN = 1100
  136. CONST BADPATH                 = 6400
  137.  
  138. ''Bitmap ID
  139. CONST LOGO = 1
  140.  
  141. GLOBAL COMPANY$
  142. GLOBAL PROGNAME$
  143. GLOBAL PRODUCTNAME$
  144. GLOBAL DEST$        ''Default destination directory.
  145.  
  146. DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
  147. DECLARE SUB MaybeAssociate (szExt$)
  148. DECLARE SUB SafeCopy(szShort$, szLong$)
  149.  
  150. INIT:
  151.     CUIDLL$ = "mscuistf.dll"            ''Custom user interface dll
  152.     HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure
  153.     COMPANY$ = "Twelve Tone Systems"
  154.  
  155.     ''Determine full SETUP.INF path+name (same name for all products).
  156.     szInf$ = GetSymbolValue("STF_SRCINFPATH")
  157.     IF szInf$ = "" THEN
  158.         szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
  159.     END IF
  160.     ReadInfFile szInf$
  161.  
  162.     ''Determine which product we are by seeing if specific section name exists.
  163.     IF DoesIniSectionExist(szInf$, "pro") <> 0 THEN
  164.         PROGNAME$ = "WINCAKE"
  165.         PRODUCTNAME$ = "Cakewalk Professional"
  166.         PROGMANGROUPNAME$ = "Cakewalk Professional"
  167.         INIBASENAME$ = "WINCAKE"
  168.         DEST$ = "C:\CPW30"
  169.     ELSEIF DoesIniSectionExist(szInf$, "demo") <> 0 THEN
  170.         PROGNAME$ = "WCWDEMO"
  171.         PRODUCTNAME$ = "Cakewalk Professional Demo"
  172.         PROGMANGROUPNAME$ = "Cakewalk Professional"
  173.         INIBASENAME$ = "WINCAKE"
  174.         DEST$ = "C:\WCWDEMO"
  175.     ELSEIF DoesIniSectionExist(szInf$, "lite") <> 0 THEN
  176.         PROGNAME$ = "CAKEHS"
  177.         PRODUCTNAME$ = "Cakewalk Home Studio"
  178.         PROGMANGROUPNAME$ = "Cakewalk Home Studio"
  179.         INIBASENAME$ = "CAKEHS"
  180.         DEST$ = "C:\CAKEHS"
  181.     ELSEIF DoesIniSectionExist(szInf$, "litedemo") <> 0 THEN
  182.         PROGNAME$ = "CHSDEMO"
  183.         PRODUCTNAME$ = "Cakewalk Home Studio Demo"
  184.         PROGMANGROUPNAME$ = "Cakewalk Home Studio"
  185.         INIBASENAME$ = "CAKEHS"
  186.         DEST$ = "C:\CHSDEMO"
  187.     ELSE
  188.         GOTO ERRQUIT
  189.     END IF
  190.  
  191.     SetBitmap CUIDLL$, LOGO
  192.     SetTitle PRODUCTNAME$ + " Setup"
  193.  
  194.     ''Check Windows version
  195.     winVerReqd$ = "3.1"
  196.     winVer$ = LTRIM$( STR$( GetWindowsMajorVersion() ) ) + "." + LTRIM$( STR$( GetWindowsMinorVersion() ) )
  197.     IF winVer$ < winVerReqd$ THEN             ''String sort works
  198.         i% = DoMsgBox( "Sorry, but your Windows version is "+winVer$+" and "+PRODUCTNAME$+" requires at least Windows "+winVerReqd$+".", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND )
  199.         END    ''exit SETUP
  200.     END IF
  201.  
  202.     ''Check CPU
  203.     cpu% = GetProcessorType()    '' 2==80286, 3==80386, 4==80486
  204.     IF cpu% < 3 THEN
  205.         i% = DoMsgBox( "Sorry, but "+PRODUCTNAME$+" requires at least an 80386 or higher CPU", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONSTOP )
  206.         END    ''exit SETUP
  207.     END IF
  208.  
  209.     ''Check for mouse
  210.     IF HasMouseInstalled() = 0 THEN
  211.         i% = DoMsgBox( "Please be aware that "+PRODUCTNAME$+" requires a mouse for many operations.", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONINFORMATION )
  212.     END IF
  213.  
  214.     ''Disk cost list symbols
  215.     FILECOSTS$   = "FileCosts"
  216.     EXTRACOSTS$  = "ExtraCosts"
  217.     STILLNEEDED$ = "StillNeeded"
  218.     FOR i% = 1 TO 26 STEP 1
  219.         AddListItem EXTRACOSTS$, "0"
  220.     NEXT i%
  221.     ''Add extra cost to Windows drive for ini/progman, etc.
  222.     ixWinDrive% = ASC(UCASE$( MID$(GetWindowsDir(), 1, 1) )) - ASC("A") + 1
  223.     ReplaceListItem EXTRACOSTS$, ixWinDrive%, "10240"
  224.  
  225.  
  226. WELCOME:
  227.     IF PROGNAME$ = "WINCAKE" THEN
  228.         dlg% = WELCOME_PRO
  229.         dlghelp% = APPHELP_PRO
  230.     ELSEIF PROGNAME$ = "WCWDEMO" THEN
  231.         dlg% = WELCOME_DEMO
  232.         dlghelp% = APPHELP_DEMO
  233.     ELSEIF PROGNAME$ = "CAKEHS" THEN
  234.         dlg% = WELCOME_LITE
  235.         dlghelp% = APPHELP_LITE
  236.     ELSEIF PROGNAME$ = "CHSDEMO" THEN
  237.         dlg% = WELCOME_LITEDEMO
  238.         dlghelp% = APPHELP_LITEDEMO
  239.     END IF
  240.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfoDlgProc", dlghelp%, HELPPROC$)
  241.     IF sz$ = "CONTINUE" THEN
  242.         UIPop 1
  243.     ELSE
  244.         GOSUB ASKQUIT
  245.         GOTO WELCOME
  246.     END IF
  247.  
  248.  
  249. GETPATH:
  250.     SetSymbolValue "EditTextIn", DEST$
  251.     SetSymbolValue "EditFocus", "END"
  252. GETPATHL1:
  253.     sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", dlghelp%, HELPPROC$)
  254.     DEST$ = GetSymbolValue("EditTextOut")
  255.  
  256.     IF sz$ = "CONTINUE" THEN
  257.         IF IsDirWritable(DEST$) = 0 THEN
  258.             GOSUB BADPATH
  259.             GOTO GETPATHL1
  260.         END IF
  261.         UIPop 1
  262.         ixAppDrive% = ASC(UCASE$( MID$(DEST$, 1, 1) )) - ASC("A") + 1
  263.     ELSEIF sz$ = "REACTIVATE" THEN
  264.         GOTO GETPATHL1
  265.     ELSEIF sz$ = "BACK" THEN
  266.         UIPop 1
  267.         GOTO WELCOME
  268.     ELSE
  269.         GOSUB ASKQUIT
  270.         GOTO GETPATH
  271.     END IF
  272.  
  273. ' Install
  274.     GOSUB INSTALL
  275.     IF StillNeed& > 0 THEN
  276.         GOTO GETPATH
  277.     END IF
  278.  
  279. QUIT:
  280.     ON ERROR GOTO ERRQUIT
  281.  
  282.     IF ERR = 0 THEN
  283.         IF PROGNAME$ = "WINCAKE" THEN
  284.             dlg% = EXITSUCCESS_PRO
  285.         ELSEIF PROGNAME$ = "WCWDEMO" THEN
  286.             dlg% = EXITSUCCESS_DEMO
  287.         ELSEIF PROGNAME$ = "CAKEHS" THEN
  288.             dlg% = EXITSUCCESS_LITE
  289.         ELSEIF PROGNAME$ = "CHSDEMO" THEN
  290.             dlg% = EXITSUCCESS_LITEDEMO
  291.         END IF
  292.     ELSEIF ERR = STFQUIT THEN
  293.         IF PROGNAME$ = "WINCAKE" THEN
  294.             dlg% = EXITQUIT_PRO
  295.         ELSEIF PROGNAME$ = "WCWDEMO" THEN
  296.             dlg% = EXITQUIT_DEMO
  297.         ELSEIF PROGNAME$ = "CAKEHS" THEN
  298.             dlg% = EXITQUIT_LITE
  299.         ELSEIF PROGNAME$ = "CHSDEMO" THEN
  300.             dlg% = EXITQUIT_LITEDEMO
  301.         END IF
  302.     ELSE
  303.         dlg% = EXITFAILURE
  304.     END IF
  305. QUITL1:
  306.     sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
  307.     IF sz$ = "REACTIVATE" THEN
  308.         GOTO QUITL1
  309.     END IF
  310.     UIPop 1
  311.  
  312.     END
  313.  
  314. ERRQUIT:
  315.     i% = DoMsgBox("Installation failure.  Call " + COMPANY$ + " Technical Support", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  316.     END
  317.  
  318.  
  319.  
  320. BADPATH:
  321.     sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
  322.     IF sz$ = "REACTIVATE" THEN
  323.         GOTO BADPATH
  324.     END IF
  325.     UIPop 1
  326.     RETURN
  327.  
  328.  
  329.  
  330. ASKQUIT:
  331.     sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
  332.  
  333.     IF sz$ = "EXIT" THEN
  334.         UIPopAll
  335.         ERROR STFQUIT
  336.     ELSEIF sz$ = "REACTIVATE" THEN
  337.         GOTO ASKQUIT
  338.     ELSE
  339.         UIPop 1
  340.     END IF
  341.     RETURN
  342.  
  343.  
  344.  
  345. '**
  346. '** Purpose:
  347. '**     Builds the copy list and performs all installation operations.
  348. '** Arguments:
  349. '**     none.
  350. '** Returns:
  351. '**     none.
  352. '*************************************************************************
  353. INSTALL:
  354.  
  355.     ' Get user information; we'll stamp later.
  356.     GOSUB DOUSERINFODIALOG
  357.  
  358.     SrcDir$ = GetSymbolValue("STF_SRCDIR")
  359.  
  360.     AddSectionFilesToCopyList "app", SrcDir$, DEST$
  361.     IF PROGNAME$ = "WINCAKE" THEN
  362.         AddSectionFilesToCopyList "pro", SrcDir$, DEST$
  363.     ELSEIF PROGNAME$ = "WCWDEMO" THEN
  364.         AddSectionFilesToCopyList "demo", SrcDir$, DEST$
  365.     ELSEIF PROGNAME$ = "CAKEHS" THEN
  366.         AddSectionFilesToCopyList "lite", SrcDir$, DEST$
  367.     ELSEIF PROGNAME$ = "CHSDEMO" THEN
  368.         AddSectionFilesToCopyList "litedemo", SrcDir$, DEST$
  369.     END IF
  370.     AddSectionFilesToCopyList "appdlls", SrcDir$, DEST$
  371.     AddSectionFilesToCopyList "system", SrcDir$, GetWindowsSysDir()
  372.  
  373.     StillNeed& = GetCopyListCost(EXTRACOSTS$, FILECOSTS$, STILLNEEDED$)
  374.     IF StillNeed& > 0 THEN
  375.         ClearCopyList
  376.         FOR ix% = 1 TO 26 STEP 1              ''find first drive that needs space
  377.             need1& = VAL(GetListItem(STILLNEEDED$, ix%))
  378.             IF need1& > 0 THEN
  379.                 GOTO FNDDRV
  380.             END IF
  381.         NEXT ix%
  382.         ix = ixAppDrive                       ''(shouldn't happen)
  383.         need1& = 0
  384.         StillNeed& = 1
  385. FNDDRV:
  386.         need$  = LTRIM$(STR$( (need1&+1023) / 1024 )) + "K bytes"
  387.         cost$  = LTRIM$(STR$( (VAL(GetListItem(FILECOSTS$, ix%))+1023) / 1024 )) + "K"
  388.         drive$ = CHR$(ix% - 1 + ASC("A")) + ":"
  389.         msg$ = "Sorry, "+PRODUCTNAME$+" needs "+need$+" more ("+cost$+" total) on drive "+drive$+".  Clear space or try a new path."
  390.         i% = DoMsgBox(msg$, "Setup Problem", MB_RETRYCANCEL+MB_TASKMODAL+MB_ICONHAND)
  391.         IF i% = IDCANCEL THEN
  392.             GOSUB ASKQUIT
  393.         END IF
  394.         RETURN          ''must RETURN out of GOSUB to pop stack, not just GOTO
  395.     END IF
  396.  
  397.     CreateDir DEST$, cmoNone
  398.  
  399.     OpenLogFile MakePath(DEST$, "LOGFILE.OUT"), 0
  400.     WriteToLogFile ""
  401.     WriteToLogFile "User chose as destination directory: '" + DEST$ + "'"
  402.     WriteToLogFile "May have had to create the directory: " + DEST$
  403.     WriteToLogFile ""
  404.  
  405.     CopyFilesInCopyList
  406.  
  407.     ' Important: Do this here before any dialogs with an Exit button, so
  408.     ' user cannot avoid stamping.
  409.     GOSUB STAMPUSERINFO
  410.  
  411.     SetRegKeyValue PROGNAME$, PRODUCTNAME$
  412.     SetRegKeyValue PROGNAME$+"\shell\print", ""
  413.     SetRegKeyValue PROGNAME$+"\shell\open\command", MakePath(DEST$,PROGNAME$+".EXE") + " %1"
  414.     MaybeAssociate "wrk"
  415.     MaybeAssociate "mid"
  416.     MaybeAssociate "mff"
  417.     MaybeAssociate "tpl"
  418.  
  419. ''Deal with old installation where our app DLL's were in WINDOWS\SYSTEM.
  420. ''No more need to delete old DLL's, since we don't use any with same name now.
  421. ''If old TTSSEQ.INI exists in sysdir but not in appdir, copy it now to preserve settings.
  422.     SysDir$ = GetWindowsSysDir()
  423.     IF DoesFileExist(SysDir$+"TTSSEQ.INI",femExists) <> 0 AND DoesFileExist(DEST$+"TTSSEQ.INI",femExists) = 0 THEN
  424.         CopyFile SysDir$+"TTSSEQ.INI", DEST$+"\TTSSEQ.INI", cmoNone, 0
  425.     END IF
  426.  
  427.     IF PROGNAME$ <> "CAKEHS" AND PROGNAME$ <> "CHSDEMO" THEN
  428.         ini$ = MakePath(DEST$, INIBASENAME$+".INI")
  429.         drm$ = MakePath(DEST$, "DRM.INI")
  430.         IF DoesFileExist(ini$,femExists) = 0 THEN
  431.             CopyFile drm$, ini$, cmoVital, 0
  432.         ELSE
  433.             sz$ = UIStartDlg(CUIDLL$, INI_NOT_OVERWRITTEN, "FInfoDlgProc", 0, "")
  434.             IF sz$ = "EXIT" THEN
  435.                 GOSUB ASKQUIT
  436.             ELSE
  437.                 UIPop 1
  438.             END IF
  439.         END IF
  440.     END IF
  441.  
  442.     SafeCopy "SRC.INS", "MASTER.INS"
  443.  
  444.     CreateProgmanGroup PROGMANGROUPNAME$, "", cmoNone
  445.     ShowProgmanGroup  PROGMANGROUPNAME$, 1, cmoNone
  446.     CreateProgmanItem PROGMANGROUPNAME$, PRODUCTNAME$, MakePath(DEST$,PROGNAME$+".EXE"), "", cmoOverwrite
  447.     CreateProgmanItem PROGMANGROUPNAME$, "README.WRI", "write.exe "+MakePath(DEST$,"readme.wri"), "", cmoOverwrite
  448.     WriteToLogFile ""
  449.  
  450.     WriteToLogFile "SUB Install completed."
  451.     CloseLogFile
  452.  
  453.     RETURN
  454.  
  455.  
  456.  
  457. '**
  458. '** Purpose:
  459. '**        Install a file without replacing an existing one.
  460. '** Arguments:
  461. '**        szShort$    - Name like SRC.INS
  462. '**        szLong$        - Name like MASTER.INS
  463. '*************************************************************************
  464. SUB SafeCopy (szShort$, szLong$) STATIC
  465.     szShortPathName$ = MakePath(DEST$, szShort$)
  466.     szLongPathName$ = MakePath(DEST$, szLong$)
  467.     IF DoesFileExist(szLongPathName$,femExists) = 0 THEN
  468.         CopyFile szShortPathName$, szLongPathName$, cmoVital, 0
  469.     END IF
  470. END SUB
  471.  
  472.  
  473.  
  474. '**
  475. '** Purpose:
  476. '**     Appends a file name to the end of a directory path,
  477. '**     inserting a backslash character as needed.
  478. '** Arguments:
  479. '**     szDir$  - full directory path (with optional ending "\")
  480. '**     szFile$ - filename to append to directory
  481. '** Returns:
  482. '**     Resulting fully qualified path name.
  483. '*************************************************************************
  484. FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
  485.     IF szDir$ = "" THEN
  486.         MakePath = szFile$
  487.     ELSEIF szFile$ = "" THEN
  488.         MakePath = szDir$
  489.     ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
  490.         MakePath = szDir$ + szFile$
  491.     ELSE
  492.         MakePath = szDir$ + "\" + szFile$
  493.     END IF
  494. END FUNCTION
  495.  
  496.  
  497.  
  498. '**
  499. '** Purpose:
  500. '** Arguments:
  501. '** Returns:
  502. '**     none.
  503. '*************************************************************************
  504. DOUSERINFODIALOG:
  505. ' Get user info for stamping later
  506.     IF PROGNAME$ <> "WCWDEMO" AND PROGNAME$ <> "CHSDEMO" THEN
  507. GETUSERINFO:
  508.         sz$ = UIStartDlg(CUIDLL$, USERINFO, "FNameOrgDlgProc", dlghelp%, HELPPROC$)
  509.         IF sz$ = "REACTIVATE" THEN
  510.             GOTO GETUSERINFO
  511.         END IF
  512.  
  513.         szUser$ = GetSymbolValue( "NameOut" )
  514.         szCo$ = GetSymbolValue( "OrgOut" )
  515.     
  516.         ' Company may be blank, but not the other two
  517.         IF szUser$ = "" THEN
  518.             msg$ = "You must supply your name or Setup cannot proceed."
  519.             i% = DoMsgBox(msg$, "Setup Problem", MB_OK+MB_TASKMODAL+MB_ICONHAND)
  520.             GOTO GETUSERINFO
  521.         END IF
  522.  
  523.         ' Dismiss dialog now that we've validated
  524.         UIPop 1
  525.     END IF
  526.  
  527.     RETURN
  528.  
  529.  
  530. '**
  531. '** Purpose:
  532. '** Arguments:
  533. '** Returns:
  534. '**     none.
  535. '*************************************************************************
  536. STAMPUSERINFO:
  537. ' Stamp user info
  538.     IF PROGNAME$ <> "WCWDEMO" AND PROGNAME$ <> "CHSDEMO" THEN
  539.  
  540.         ' szUser$ szCo$ were prompted for above
  541.         szDat$ = CHR$(LEN(szUser$)) + szUser$
  542.         szDat$ = szDat$ + CHR$(LEN(szCo$)) + szCo$
  543.  
  544.         IF PROGNAME$ = "WINCAKE" THEN
  545.             szInfSect$ = "pro"
  546.         ELSEIF PROGNAME$ = "CAKEHS" THEN
  547.             szInfSect$ = "lite"
  548.         END IF
  549.     
  550.         ' 6 is the resource type for STRINGTABLE entries
  551.         '
  552.         ' &H401 is the upper 12 bits of IDS_USERNAME (0x4000) + 1.
  553.         '
  554.         ' In DSKLAYT we specified a reference key for the .EXE which
  555.         ' is the same as PROGNAME$.
  556.         StampResource szInfSect$,PROGNAME$,DEST$,6,&H401,szDat$,LEN(szDat$)
  557.     END IF
  558.  
  559.     RETURN
  560.  
  561.  
  562. '**
  563. '** Purpose:
  564. '**     Associates given filetype with us, but asks for user confirmation
  565. '**     if already set to something else.
  566. '** Arguments:
  567. '**     szExt$ - filetype extension, e.g. "mid"
  568. '** Returns:
  569. '**     none.
  570. '*************************************************************************
  571. SUB MaybeAssociate (szExt$) STATIC
  572.     oldProg$ = ""
  573.     ok% = IDYES
  574.  
  575. 'Check Registration Database (overrides WIN.INI [Extensions]).
  576.  
  577.     oldCmd$ = UCASE$( LTRIM$( GetRegKeyValue("."+szExt$+"\shell\open\command") ) )
  578.     IF oldCmd$ = "" THEN    'didn't find direct association, check via prog name
  579.         oldProg$ = LTRIM$( RTRIM$( GetRegKeyValue("."+szExt$) ) )
  580.         IF oldProg$ <> "" THEN
  581.             oldCmd$ = UCASE$( LTRIM$( GetRegKeyValue(oldProg$+"\shell\open\command") ) )
  582.             oldProduct$ = LTRIM$( RTRIM$( GetRegKeyValue(oldProg$) ) )
  583.             IF oldProduct$ <> "" THEN    'long product name found, use it
  584.                 oldProg$ = oldProduct$
  585.             END IF
  586.         END IF
  587.     END IF
  588.     IF oldCmd$ <> "" THEN
  589.         IF INSTR(oldCmd$, PROGNAME$+".EXE") = 0 THEN    'not us, must confirm
  590.             IF oldProg$ = "" THEN   'no short or long name, parse command string
  591.                 j% = INSTR(oldCmd$, " ")
  592.                 IF j% > 1 THEN
  593.                     oldProg$ = MID$(oldCmd$, 1, j%-1)
  594.                 ELSE
  595.                     oldProg$ = oldCmd$
  596.                 END IF
  597.             END IF
  598.         ELSE                            'it's us, clear oldProg$ => no confirm
  599.             oldProg$ = ""
  600.         END IF
  601.         GOTO MAYBE_CONFIRM      'found association, no need to examine WIN.INI
  602.     END IF
  603.  
  604. 'Check WIN.INI [Extensions].
  605.  
  606.     oldCmd$ = UCASE$( LTRIM$( GetIniKeyString("WIN.INI","Extensions",szExt$) ) )
  607.     IF oldCmd$ <> "" THEN
  608.         IF INSTR(oldCmd$, PROGNAME$+".EXE") = 0 THEN    'not us, must confirm
  609.             j% = INSTR(oldCmd$, " ")
  610.             IF j% > 1 THEN
  611.                 oldProg$ = MID$(oldCmd$, 1, j%-1)
  612.             ELSE
  613.                 oldProg$ = oldCmd$
  614.             END IF
  615.         END IF
  616.     END IF
  617.  
  618. 'Get user confirmation if necessary, and do the association if ok.
  619.  
  620. MAYBE_CONFIRM:
  621.     IF oldProg$ <> "" THEN
  622.         ok% = DoMsgBox("."+UCASE$(szExt$)+" files are currently associated with "+oldProg$+".  Switch association to "+PRODUCTNAME$+"?", "Setup Question", MB_YESNO+MB_TASKMODAL+MB_ICONQUESTION)
  623.     END IF
  624.  
  625.     IF ok% = IDYES THEN
  626.         DeleteRegKey   "."+szExt$       'delete all keys for any old direct association
  627.         SetRegKeyValue "."+szExt$, PROGNAME$
  628.         CreateIniKeyValue "WIN.INI", "Extensions", szExt$, MakePath(DEST$,PROGNAME$+".EXE") + " ^." + szExt$, cmoOverwrite
  629.     END IF
  630.  
  631. END SUB
  632.