home *** CD-ROM | disk | FTP | other *** search
/ Multimedia Classic / MultimediaClassic.mdf / app_midi / cake2pro / disk1 / wincake.ms_ / wincake.bin
Encoding:
Text File  |  1993-05-23  |  17.9 KB  |  568 lines

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