home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Magazin 1995 November
/
CD_11_95.BIN
/
cakewalk
/
wincake.ms_
/
wincake.bin
Wrap
Text File
|
1995-02-14
|
34KB
|
841 lines
'**************************************************************************
'* $Header: G:/SRC/WCW/MSSETUP/VCS/WINCAKE.MSV 1.33 20 Dec 1994 16:16:28 PS $
'*
'* DESCRIPTION: MS-Setup script for Wincake and Wcwdemo.
'*
'* $Log: G:/SRC/WCW/MSSETUP/VCS/WINCAKE.MSV $
'*
'* Rev 1.33 20 Dec 1994 16:16:28 PS
'* Final directory names for 3.01 RC1.
'*
'* Rev 1.32 20 Dec 1994 12:53:50 PS
'* Add VPIANO to Pro & Pro Demo.
'*
'* Rev 1.31 13 Dec 1994 18:48:20 PS
'* Added DEFAULT.INS, INS_NOT_OVERWRITTEN dialog.
'*
'* Rev 1.30 01 Dec 1994 16:43:38 PS
'* New, separate-product production method. Many changes for 3.01 Beta B.
'*
'* Rev 1.29 14 Nov 1994 19:31:14 PS
'* Set dest directory for beta testers.
'*
'* Rev 1.28 11 Nov 1994 19:06:48 PS
'* CAKEXP.EXE. Allow layout per product.
'*
'* Rev 1.27 09 May 1994 13:19:02 GH
'* Detect/require 80386 or higher, warn about no mouse.
'*
'* Rev 1.26 28 Apr 1994 21:26:02 GH
'* Use SRC.INS and MASTER.INS
'*
'* Rev 1.25 25 Apr 1994 13:40:06 GH
'* For CPW, changed DEST$ to C:\CPW30
'*
'* Rev 1.24 15 Apr 1994 15:34:48 GH
'* Changes for 2.5 Beta
'*
'* Rev 1.23 17 Feb 1994 13:17:14 PS
'* Associate .TPL files with us, too.
'*
'* Rev 1.22 11 Jan 1994 13:47:38 CP
'* Create a Home Studio Demo version.
'*
'* Rev 1.21 08 Nov 1993 15:41:42 CP
'* Change Lite name from WCWLITE to CAKEHS.
'*
'* Rev 1.20 23 Aug 1993 14:06:06 CP
'* Default installation directory for Demo is now C:\WCWDEMO to prevent
'* nuking of previous installations.
'*
'* Rev 1.19 24 May 1993 17:09:22 gwh
'* Removed serial number item from user info prompt.
'*
'* Rev 1.18 18 Apr 1993 17:50:40 gwh
'* More refinements for user name, organization, serial number stamping.
'*
'* Rev 1.17 01 Apr 1993 18:32:44 gwh
'* Prompt user for Name, Organization, and Serial number.
'* Stamp the .EXE resources for these items.
'*
'* Rev 1.16 18 Mar 1993 14:06:42 pws
'* No more need to clean up old DLL's in Windows sys dir (or TTSSEQ.INI).
'* Also check for existence of TTSSEQ.INI in install dir before copying
'* any TTSSEQ.INI found in Windows sys dir before copying new files.
'*
'* Rev 1.15 05 Mar 1993 12:08:38 pws
'* Fix support for multiple-disk installations, which had broken when
'* we started determining which product we were by testing for the
'* existence of name.EXE on the first diskette but it had been put
'* on the second one. Now determine which product we are by testing
'* for existence of product-specific section in SETUP.INF file.
'*
'* Rev 1.14 22 Dec 1992 13:17:36 pws
'* Reflect changed dialog id's in BLDCUI\DIALOGS.H.
'*
'* Rev 1.13 15 Dec 1992 14:47:18 pws
'* Added CTL3D.DLL.
'*
'* Rev 1.12 10 Nov 1992 12:37:56 pws
'* Made more dialogs product-specific.
'*
'* ---
'* See logfile for earlier revision comments
'*
'* Copyright (C) 1990- by Greg Hendershott. All rights reserved.
'**************************************************************************
'$INCLUDE 'setupapi.inc'
'$INCLUDE 'msdetect.inc'
'$INCLUDE 'msregdb.inc'
'These should have all been in SETUPAPI.INC.
'Note that duplicate definitions are errors and so are commented out!
'CONST MB_OK = &H0000
CONST MB_OKCANCEL = &H0001
CONST MB_ABORTRETRYIGNORE = &H0002
CONST MB_YESNOCANCEL = &H0003
CONST MB_YESNO = &H0004
CONST MB_RETRYCANCEL = &H0005
CONST MB_TYPEMASK = &H000F
'CONST MB_ICONHAND = &H0010
CONST MB_ICONQUESTION = &H0020
CONST MB_ICONEXCLAMATION = &H0030
CONST MB_ICONASTERISK = &H0040
CONST MB_ICONMASK = &H00F0
CONST MB_ICONINFORMATION = MB_ICONASTERISK
CONST MB_ICONSTOP = MB_ICONHAND
CONST MB_DEFBUTTON1 = &H0000
CONST MB_DEFBUTTON2 = &H0100
CONST MB_DEFBUTTON3 = &H0200
CONST MB_DEFMASK = &H0F00
CONST MB_APPLMODAL = &H0000
CONST MB_SYSTEMMODAL = &H1000
'CONST MB_TASKMODAL = &H2000
CONST MB_NOFOCUS = &H8000
CONST IDOK = 1
CONST IDCANCEL = 2
CONST IDABORT = 3
CONST IDRETRY = 4
CONST IDIGNORE = 5
CONST IDYES = 6
CONST IDNO = 7
'Dialog ID's. NOTE: THIS MUST MATCH BLDCUI\DIALOGS.H!
CONST WELCOME_PR = 170
CONST WELCOME_PD = 171
CONST WELCOME_HS = 172
CONST WELCOME_HD = 173
CONST WELCOME_XP = 174
CONST WELCOME_XD = 175
CONST ASKQUIT = 200
CONST DESTPATH = 300
CONST USERINFO = 310
CONST EXITFAILURE = 400
CONST EXITQUIT_PR = 670
CONST EXITQUIT_PD = 671
CONST EXITQUIT_HS = 672
CONST EXITQUIT_HD = 673
CONST EXITQUIT_XP = 674
CONST EXITQUIT_XD = 675
CONST EXITSUCCESS_PR = 770
CONST EXITSUCCESS_PD = 771
CONST EXITSUCCESS_HS = 772
CONST EXITSUCCESS_HD = 773
CONST EXITSUCCESS_XP = 774
CONST EXITSUCCESS_XD = 775
CONST APPHELP_PR = 970
CONST APPHELP_PD = 971
CONST APPHELP_HS = 972
CONST APPHELP_HD = 973
CONST APPHELP_XP = 974
CONST APPHELP_XD = 975
CONST INI_NOT_OVERWRITTEN = 1000
CONST INS_NOT_OVERWRITTEN = 1100
CONST BADPATH = 6400
'Bitmap ID.
CONST LOGO = 1
GLOBAL COMPANY$
GLOBAL PROGNAME$
GLOBAL PRODUCTNAME$
GLOBAL DEST$ 'Default destination directory.
DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
DECLARE SUB MaybeAssociate (szExt$)
DECLARE SUB SafeCopy(szShort$, szLong$)
DECLARE FUNCTION ArgStr$ (Fmt$, Arg1$, Arg2$, Arg3$, Arg4$)
INIT:
'======== beg LOCALIZATION ========
'These are the strings that need to be localized for different languages.
'Every one of them is located right here in this block.
CONST COMPANY_$ = "Twelve Tone Systems"
CONST PRODUCTNAME_PR_$ = "Cakewalk Professional"
CONST PRODUCTNAME_PD_$ = "Demoversion von Cakewalk Professional"
CONST PRODUCTNAME_HS_$ = "Cakewalk Home Studio"
CONST PRODUCTNAME_HD_$ = "Demoversion von Cakewalk Home Studio"
CONST PRODUCTNAME_XP_$ = "Cakewalk Express"
CONST PRODUCTNAME_XD_$ = "Demoversion von Cakewalk Express"
CONST PROGMANGROUPNAME_PR_$ = "Cakewalk Professional"
CONST PROGMANGROUPNAME_HS_$ = "Cakewalk Home Studio"
CONST PROGMANGROUPNAME_XP_$ = "Cakewalk Express"
CONST SETUP_$ = "Installation von"
CONST SetTitleFmt_$ = "\2 \1"
CONST setupMessage_$ = "Meldung zur Installation"
CONST setupProblem_$ = "Poblem bei der Installation"
CONST setupQuestion_$ = "Frage zur Installation"
CONST winVerFmt_$ = "Sie verwenden Windows Version \1. \2 ben÷tigt mindestens Windows \3."
CONST cpuFmt_$ = "\1 setzt mindestens einen 80386er oder schnelleren Rechner voraus."
CONST mouseFmt_$ = "Viele Funktionen unter \1 werden mit der Maus ausgefⁿhrt."
CONST errQuitFmt_$ = "Die Installation ist fehlgeschlagen. Wenden Sie sich an den technischen Support von \1."
CONST driveBase_$ = "A" 'drive letters start at this char
CONST dskSpcFmt_$ = "\1 ben÷tigt \2 KB mehr (insgesamt \3 KB) auf Laufwerk \4:. Schaffen Sie mehr Speicherplatz."
CONST userInfoNeedName_$ = "Zur Fortsetzung der Installation mⁿssen Sie Ihren Namen eingeben."
CONST assocConfirmFmt_$ = ".\1 ist zur Zeit \2 zugeordnet. Wollen Sie sie \3 zuordnen?"
CONST PRODUCTNAME_VP_$ = "Virtual Piano"
CONST instMustRestartWinFmt_$ = "\1 wurde installiert. Zur Verwendung des Programms mⁿssen Sie Windows neu starten."
'======== end LOCALIZATION ========
CUIDLL$ = "mscuistf.dll" 'Custom user interface dll
HELPPROC$ = "FHelpDlgProc" 'Help dialog procedure
'Determine full SETUP.INF path+name (same name for all products).
szInf$ = GetSymbolValue("STF_SRCINFPATH")
IF szInf$ = "" THEN
szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
END IF
ReadInfFile szInf$
'Determine which product we are by seeing which .EXE name reference key
'is defined. In DSKLAYT we specified a reference key for the .EXE which
'is the same as PROGNAME$. This key is also used for StampResource below.
IF DoesIniKeyExist(szInf$, "Files", """WINCAKE""") <> 0 THEN
PROGNAME$ = "WINCAKE"
PRODUCTNAME$ = PRODUCTNAME_PR_$
PROGMANGROUPNAME$ = PROGMANGROUPNAME_PR_$
INIBASENAME$ = "WINCAKE"
DEST$ = "C:\CPW30" 'normal
' DEST$ = "C:\CPW301" 'temp during beta test period
ELSEIF DoesIniKeyExist(szInf$, "Files", """WCWDEMO""") <> 0 THEN
PROGNAME$ = "WCWDEMO"
PRODUCTNAME$ = PRODUCTNAME_PD_$
PROGMANGROUPNAME$ = PROGMANGROUPNAME_PR_$
INIBASENAME$ = "WINCAKE"
DEST$ = "C:\WCWDEMO"
ELSEIF DoesIniKeyExist(szInf$, "Files", """CAKEHS""") <> 0 THEN
PROGNAME$ = "CAKEHS"
PRODUCTNAME$ = PRODUCTNAME_HS_$
PROGMANGROUPNAME$ = PROGMANGROUPNAME_HS_$
INIBASENAME$ = "CAKEHS"
DEST$ = "C:\CAKEHS" 'normal
' DEST$ = "C:\CHS301" 'temp during beta test period
ELSEIF DoesIniKeyExist(szInf$, "Files", """CHSDEMO""") <> 0 THEN
PROGNAME$ = "CHSDEMO"
PRODUCTNAME$ = PRODUCTNAME_HD_$
PROGMANGROUPNAME$ = PROGMANGROUPNAME_HS_$
INIBASENAME$ = "CAKEHS"
DEST$ = "C:\CHSDEMO"
ELSEIF DoesIniKeyExist(szInf$, "Files", """CAKEXP""") <> 0 THEN
PROGNAME$ = "CAKEXP"
PRODUCTNAME$ = PRODUCTNAME_XP_$
PROGMANGROUPNAME$ = PROGMANGROUPNAME_XP_$
INIBASENAME$ = "CAKEXP"
DEST$ = "C:\CAKEXP" 'normal
' DEST$ = "C:\CXP301" 'temp during beta test period
ELSEIF DoesIniKeyExist(szInf$, "Files", """CAKEXPD""") <> 0 THEN
PROGNAME$ = "CAKEXPD"
PRODUCTNAME$ = PRODUCTNAME_XD_$
PROGMANGROUPNAME$ = PROGMANGROUPNAME_XP_$
INIBASENAME$ = "CAKEXP"
DEST$ = "C:\CAKEXPD"
ELSE
GOTO ERRQUIT
END IF
SetBitmap CUIDLL$, LOGO
SetTitle ArgStr$(SetTitleFmt_$, PRODUCTNAME$, SETUP_$, "", "")
'Check Windows version.
winVerReqd$ = "3.1"
winVer$ = LTRIM$( STR$( GetWindowsMajorVersion() ) ) + "." + LTRIM$( STR$( GetWindowsMinorVersion() ) )
IF winVer$ < winVerReqd$ THEN 'string sort works
i% = DoMsgBox( ArgStr$(winVerFmt_$, winVer$, PRODUCTNAME$, winVerReqd$, ""), setupMessage_$, MB_OK+MB_TASKMODAL+MB_ICONHAND )
END 'exit SETUP
END IF
'Check CPU.
cpu% = GetProcessorType() '2==80286, 3==80386, 4==80486
IF cpu% < 3 THEN
i% = DoMsgBox( ArgStr$(cpuFmt_$, PRODUCTNAME$, "", "", ""), setupMessage_$, MB_OK+MB_TASKMODAL+MB_ICONSTOP )
END 'exit SETUP
END IF
'Check for mouse.
IF HasMouseInstalled() = 0 THEN
i% = DoMsgBox( ArgStr$(mouseFmt_$, PRODUCTNAME$, "", "", ""), setupMessage_$, MB_OK+MB_TASKMODAL+MB_ICONINFORMATION )
END IF
'Disk cost list symbols.
FILECOSTS$ = "FileCosts"
EXTRACOSTS$ = "ExtraCosts"
STILLNEEDED$ = "StillNeeded"
FOR i% = 1 TO 26 STEP 1
AddListItem EXTRACOSTS$, "0"
NEXT i%
'Add extra cost to Windows drive for ini/progman, etc.
ixWinDrive% = ASC(UCASE$( MID$(GetWindowsDir(), 1, 1) )) - ASC("A") + 1
ReplaceListItem EXTRACOSTS$, ixWinDrive%, "10240"
WELCOME:
IF PROGNAME$ = "WINCAKE" THEN
dlg% = WELCOME_PR
dlghelp% = APPHELP_PR
ELSEIF PROGNAME$ = "WCWDEMO" THEN
dlg% = WELCOME_PD
dlghelp% = APPHELP_PD
ELSEIF PROGNAME$ = "CAKEHS" THEN
dlg% = WELCOME_HS
dlghelp% = APPHELP_HS
ELSEIF PROGNAME$ = "CHSDEMO" THEN
dlg% = WELCOME_HD
dlghelp% = APPHELP_HD
ELSEIF PROGNAME$ = "CAKEXP" THEN
dlg% = WELCOME_XP
dlghelp% = APPHELP_XP
ELSEIF PROGNAME$ = "CAKEXPD" THEN
dlg% = WELCOME_XD
dlghelp% = APPHELP_XD
END IF
sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfoDlgProc", dlghelp%, HELPPROC$)
IF sz$ = "CONTINUE" THEN
UIPop 1
ELSE
GOSUB ASKQUIT
GOTO WELCOME
END IF
GETPATH:
SetSymbolValue "EditTextIn", DEST$
SetSymbolValue "EditFocus", "END"
GETPATHL1:
sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", dlghelp%, HELPPROC$)
DEST$ = GetSymbolValue("EditTextOut")
IF sz$ = "CONTINUE" THEN
IF IsDirWritable(DEST$) = 0 THEN
GOSUB BADPATH
GOTO GETPATHL1
END IF
UIPop 1
ixAppDrive% = ASC(UCASE$( MID$(DEST$, 1, 1) )) - ASC(driveBase_$) + 1
ELSEIF sz$ = "REACTIVATE" THEN
GOTO GETPATHL1
ELSEIF sz$ = "BACK" THEN
UIPop 1
GOTO WELCOME
ELSE
GOSUB ASKQUIT
GOTO GETPATH
END IF
'Install.
GOSUB INSTALL
IF StillNeed& > 0 THEN
GOTO GETPATH
END IF
QUIT:
ON ERROR GOTO ERRQUIT
IF ERR = 0 THEN
IF PROGNAME$ = "WINCAKE" THEN
dlg% = EXITSUCCESS_PR
ELSEIF PROGNAME$ = "WCWDEMO" THEN
dlg% = EXITSUCCESS_PD
ELSEIF PROGNAME$ = "CAKEHS" THEN
dlg% = EXITSUCCESS_HS
ELSEIF PROGNAME$ = "CHSDEMO" THEN
dlg% = EXITSUCCESS_HD
ELSEIF PROGNAME$ = "CAKEXP" THEN
dlg% = EXITSUCCESS_XP
ELSEIF PROGNAME$ = "CAKEXPD" THEN
dlg% = EXITSUCCESS_XD
END IF
ELSEIF ERR = STFQUIT THEN
IF PROGNAME$ = "WINCAKE" THEN
dlg% = EXITQUIT_PR
ELSEIF PROGNAME$ = "WCWDEMO" THEN
dlg% = EXITQUIT_PD
ELSEIF PROGNAME$ = "CAKEHS" THEN
dlg% = EXITQUIT_HS
ELSEIF PROGNAME$ = "CHSDEMO" THEN
dlg% = EXITQUIT_HD
ELSEIF PROGNAME$ = "CAKEXP" THEN
dlg% = EXITQUIT_XP
ELSEIF PROGNAME$ = "CAKEXPD" THEN
dlg% = EXITQUIT_XD
END IF
ELSE
dlg% = EXITFAILURE
END IF
QUITL1:
sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO QUITL1
END IF
UIPop 1
END
ERRQUIT:
i% = DoMsgBox(ArgStr$(errQuitFmt_$, COMPANY_$, "", "", ""), setupMessage_$, MB_OK+MB_TASKMODAL+MB_ICONHAND)
END
BADPATH:
sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "")
IF sz$ = "REACTIVATE" THEN
GOTO BADPATH
END IF
UIPop 1
RETURN
ASKQUIT:
sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
IF sz$ = "EXIT" THEN
UIPopAll
ERROR STFQUIT
ELSEIF sz$ = "REACTIVATE" THEN
GOTO ASKQUIT
ELSE
UIPop 1
END IF
RETURN
'**
'** Purpose:
'** Builds the copy list and performs all installation operations.
'** Arguments:
'** none.
'** Returns:
'** none.
'*************************************************************************
INSTALL:
'Get user information; we'll stamp later.
GOSUB DOUSERINFODIALOG
SrcDir$ = GetSymbolValue("STF_SRCDIR")
'These (normal) files go to the user's specifed app destination directory.
AddSectionFilesToCopyList "Files", SrcDir$, DEST$
'These files go to the Windows System directory.
AddSectionFilesToCopyList "system", SrcDir$, GetWindowsSysDir()
StillNeed& = GetCopyListCost(EXTRACOSTS$, FILECOSTS$, STILLNEEDED$)
IF StillNeed& > 0 THEN
ClearCopyList
FOR ix% = 1 TO 26 STEP 1 'find first drive that needs space
need1& = VAL(GetListItem(STILLNEEDED$, ix%))
IF need1& > 0 THEN
GOTO FNDDRV
END IF
NEXT ix%
ix = ixAppDrive '(shouldn't happen)
need1& = 0
StillNeed& = 1
FNDDRV:
need$ = LTRIM$(STR$( (need1&+1023) / 1024 ))
cost$ = LTRIM$(STR$( (VAL(GetListItem(FILECOSTS$, ix%))+1023) / 1024 ))
drive$ = CHR$(ix% - 1 + ASC(driveBase_$))
msg$ = ArgStr$(dskSpcFmt_$, PRODUCTNAME$, need$, cost$, drive$)
i% = DoMsgBox(msg$, setupProblem_$, MB_RETRYCANCEL+MB_TASKMODAL+MB_ICONHAND)
IF i% = IDCANCEL THEN
GOSUB ASKQUIT
END IF
RETURN 'must RETURN out of GOSUB to pop stack, not just GOTO
END IF
CreateDir DEST$, cmoNone
OpenLogFile MakePath(DEST$, "LOGFILE.OUT"), 0
WriteToLogFile ""
WriteToLogFile "User chose as destination directory: '" + DEST$ + "'"
WriteToLogFile "May have had to create the directory: " + DEST$
WriteToLogFile ""
CopyFilesInCopyList
'Important: Do this here before any dialogs with an Exit button, so
'user cannot avoid stamping.
GOSUB STAMPUSERINFO
SetRegKeyValue PROGNAME$, PRODUCTNAME$
SetRegKeyValue PROGNAME$+"\shell\print", ""
SetRegKeyValue PROGNAME$+"\shell\open\command", MakePath(DEST$,PROGNAME$+".EXE") + " %1"
MaybeAssociate "wrk"
MaybeAssociate "mid"
MaybeAssociate "mff"
MaybeAssociate "tpl"
'Deal with old installation where our app DLL's were in WINDOWS\SYSTEM.
'No more need to delete old DLL's, since we don't use any with same name now.
'If old TTSSEQ.INI exists in sysdir but not in appdir, copy it now to preserve settings.
SysDir$ = GetWindowsSysDir()
IF DoesFileExist(SysDir$+"TTSSEQ.INI",femExists) <> 0 AND DoesFileExist(DEST$+"TTSSEQ.INI",femExists) = 0 THEN
CopyFile SysDir$+"TTSSEQ.INI", DEST$+"\TTSSEQ.INI", cmoNone, 0
END IF
'If this product includes sysx input support, then it includes DRM.INI, which
'is the base version of progname.INI containing just the DRM's.
'So if this product includes DRM.INI, then copy it to progname.INI, except if
'progname.INI already exists, in which case we inform the user that we didn't
'overwrite it and he might want to look for new DRM's in DRM.INI.
drm$ = MakePath(DEST$, "DRM.INI")
ini$ = MakePath(DEST$, INIBASENAME$+".INI")
IF DoesFileExist(drm$,femExists) <> 0 THEN 'if this product includes DRM.INI
IF DoesFileExist(ini$,femExists) = 0 THEN
CopyFile drm$, ini$, cmoVital, 0
ELSE
sz$ = UIStartDlg(CUIDLL$, INI_NOT_OVERWRITTEN, "FInfoDlgProc", 0, "")
IF sz$ = "EXIT" THEN
GOSUB ASKQUIT
ELSE
UIPop 1
END IF
END IF
END IF
'SRC.INS (complete .INS) was copied over with no name change.
'DEFAULT.INS (basic default .INS) will be copied to MASTER.INS, which is
'what the program actually uses, but only if it doesn't already exist.
default$ = MakePath(DEST$, "DEFAULT.INS")
master$ = MakePath(DEST$, "MASTER.INS")
IF DoesFileExist(master$,femExists) = 0 THEN
CopyFile default$, master$, cmoVital, 0
ELSE
sz$ = UIStartDlg(CUIDLL$, INS_NOT_OVERWRITTEN, "FInfoDlgProc", 0, "")
IF sz$ = "EXIT" THEN
GOSUB ASKQUIT
ELSE
UIPop 1
END IF
END IF
CreateProgmanGroup PROGMANGROUPNAME$, "", cmoNone
ShowProgmanGroup PROGMANGROUPNAME$, 1, cmoNone
CreateProgmanItem PROGMANGROUPNAME$, PRODUCTNAME$, MakePath(DEST$,PROGNAME$+".EXE"), "", cmoOverwrite
CreateProgmanItem PROGMANGROUPNAME$, "README.WRI", "write.exe "+MakePath(DEST$,"readme.wri"), "", cmoOverwrite
WriteToLogFile ""
GOSUB INSTALL_VPIANO
WriteToLogFile "SUB Install completed."
CloseLogFile
RETURN
'**
'** Purpose:
'** Install a file without replacing an existing one.
'** Arguments:
'** szShort$ - Name like SRC.INS
'** szLong$ - Name like MASTER.INS
'*************************************************************************
SUB SafeCopy (szShort$, szLong$) STATIC
szShortPathName$ = MakePath(DEST$, szShort$)
szLongPathName$ = MakePath(DEST$, szLong$)
IF DoesFileExist(szLongPathName$,femExists) = 0 THEN
CopyFile szShortPathName$, szLongPathName$, cmoVital, 0
END IF
END SUB
'**
'** Purpose:
'** Appends a file name to the end of a directory path,
'** inserting a backslash character as needed.
'** Arguments:
'** szDir$ - full directory path (with optional ending "\")
'** szFile$ - filename to append to directory
'** Returns:
'** Resulting fully qualified path name.
'*************************************************************************
FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
IF szDir$ = "" THEN
MakePath = szFile$
ELSEIF szFile$ = "" THEN
MakePath = szDir$
ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN
MakePath = szDir$ + szFile$
ELSE
MakePath = szDir$ + "\" + szFile$
END IF
END FUNCTION
'**
'** Purpose:
'** Arguments:
'** Returns:
'** none.
'*************************************************************************
DOUSERINFODIALOG:
'Get user info for stamping later.
IF PROGNAME$ <> "WCWDEMO" AND PROGNAME$ <> "CHSDEMO" AND PROGNAME$ <> "CAKEXPD" THEN
GETUSERINFO:
sz$ = UIStartDlg(CUIDLL$, USERINFO, "FNameOrgDlgProc", dlghelp%, HELPPROC$)
IF sz$ = "REACTIVATE" THEN
GOTO GETUSERINFO
END IF
szUser$ = GetSymbolValue( "NameOut" )
szCo$ = GetSymbolValue( "OrgOut" )
'Company may be blank, but not the other two.
IF szUser$ = "" THEN
i% = DoMsgBox(userInfoNeedName_$, setupProblem_$, MB_OK+MB_TASKMODAL+MB_ICONHAND)
GOTO GETUSERINFO
END IF
'Dismiss dialog now that we've validated.
UIPop 1
END IF
RETURN
'**
'** Purpose:
'** Arguments:
'** Returns:
'** none.
'*************************************************************************
STAMPUSERINFO:
'Stamp user info into our .EXE file.
IF PROGNAME$ <> "WCWDEMO" AND PROGNAME$ <> "CHSDEMO" AND PROGNAME$ <> "CAKEXPD" THEN
'szUser$ szCo$ were prompted for above.
szDat$ = CHR$(LEN(szUser$)) + szUser$
szDat$ = szDat$ + CHR$(LEN(szCo$)) + szCo$
'"Files" is the section name in our .INF file of the .EXE file.
'
'6 is the resource type for STRINGTABLE entries.
'
'&H401 is the upper 12 bits of IDS_USERNAME (0x4000) + 1.
'
'In DSKLAYT we specified a reference key for the .EXE which
'is the same as PROGNAME$.
StampResource "Files",PROGNAME$,DEST$,6,&H401,szDat$,LEN(szDat$)
END IF
RETURN
'**
'** Purpose:
'** Associates given filetype with us, but asks for user confirmation
'** if already set to something else.
'** Arguments:
'** szExt$ - filetype extension, e.g. "mid"
'** Returns:
'** none.
'*************************************************************************
SUB MaybeAssociate (szExt$) STATIC
oldProg$ = ""
ok% = IDYES
'Check Registration Database (overrides WIN.INI [Extensions]).
oldCmd$ = UCASE$( LTRIM$( GetRegKeyValue("."+szExt$+"\shell\open\command") ) )
IF oldCmd$ = "" THEN 'didn't find direct association, check via prog name
oldProg$ = LTRIM$( RTRIM$( GetRegKeyValue("."+szExt$) ) )
IF oldProg$ <> "" THEN
oldCmd$ = UCASE$( LTRIM$( GetRegKeyValue(oldProg$+"\shell\open\command") ) )
oldProduct$ = LTRIM$( RTRIM$( GetRegKeyValue(oldProg$) ) )
IF oldProduct$ <> "" THEN 'long product name found, use it
oldProg$ = oldProduct$
END IF
END IF
END IF
IF oldCmd$ <> "" THEN
IF INSTR(oldCmd$, PROGNAME$+".EXE") = 0 THEN 'not us, must confirm
IF oldProg$ = "" THEN 'no short or long name, parse command string
j% = INSTR(oldCmd$, " ")
IF j% > 1 THEN
oldProg$ = MID$(oldCmd$, 1, j%-1)
ELSE
oldProg$ = oldCmd$
END IF
END IF
ELSE 'it's us, clear oldProg$ => no confirm
oldProg$ = ""
END IF
GOTO MAYBE_CONFIRM 'found association, no need to examine WIN.INI
END IF
'Check WIN.INI [Extensions].
oldCmd$ = UCASE$( LTRIM$( GetIniKeyString("WIN.INI","Extensions",szExt$) ) )
IF oldCmd$ <> "" THEN
IF INSTR(oldCmd$, PROGNAME$+".EXE") = 0 THEN 'not us, must confirm
j% = INSTR(oldCmd$, " ")
IF j% > 1 THEN
oldProg$ = MID$(oldCmd$, 1, j%-1)
ELSE
oldProg$ = oldCmd$
END IF
END IF
END IF
'Get user confirmation if necessary, and do the association if ok.
MAYBE_CONFIRM:
IF oldProg$ <> "" THEN
ok% = DoMsgBox(ArgStr$(assocConfirmFmt_$, UCASE$(szExt$), oldProg$, PRODUCTNAME$, ""), setupQuestion_$, MB_YESNO+MB_TASKMODAL+MB_ICONQUESTION)
END IF
IF ok% = IDYES THEN
DeleteRegKey "."+szExt$ 'delete all keys for any old direct association
SetRegKeyValue "."+szExt$, PROGNAME$
CreateIniKeyValue "WIN.INI", "Extensions", szExt$, MakePath(DEST$,PROGNAME$+".EXE") + " ^." + szExt$, cmoOverwrite
END IF
END SUB
'**
'** Purpose:
'** Installs Virtual Piano and its driver, if part of this product.
'** Arguments:
'** none.
'** Returns:
'** none.
'** WARNING:
'** The current method used here only works with Windows 3.1!
'*************************************************************************
INSTALL_VPIANO:
'If this product doesn't include the Virtual Piano, return now.
'(Currently all products include it.)
'Set up the Virtual Piano program icon.
CreateProgmanItem PROGMANGROUPNAME$, PRODUCTNAME_VP_$, MakePath(DEST$,"VPIANO.EXE"), "", cmoOverwrite
'Display message that it was installed and Windows should be restarted.
i% = DoMsgBox( ArgStr$(instMustRestartWinFmt_$, PRODUCTNAME_VP_$, "", "", ""), setupMessage_$, MB_OK+MB_TASKMODAL+MB_ICONINFORMATION )
'If there's already a SYSTEM.INI [drivers] MIDIn key set to us, we're done.
'Else find next available SYSTEM.INI [drivers] MIDIn key.
szSysIni$ = GetWindowsDir()+"SYSTEM.INI"
szSect$ = "drivers"
szValue$ = "vpiano.drv"
szKey$ = "MIDI99"
FOR i% = 0 TO 98 STEP 1
IF i% = 0 THEN
szKeyThis$ = "MIDI"
ELSE
szKeyThis$ = "MIDI" + LTRIM$( STR$(i%) )
END IF
szOldValue$ = LCASE$( GetIniKeyString(szSysIni$,szSect$,szKeyThis$) )
IF szOldValue$ = szValue$ THEN
RETURN 'already set, we're done
ELSEIF szOldValue$ = "" AND szKey$ = "MIDI99" THEN
szKey$ = szKeyThis$ 'found next key, remember it
END IF
NEXT i%
'Found next available SYSTEM.INI [drivers] MIDIn key. Set it to point to us.
CreateIniKeyValue szSysIni$, szSect$, szKey$, szValue$, cmoNone
RETURN
'**
'** Purpose:
'** Substitutes string args by number into a format string.
'** Useful for localization, since arg order is now controlled by Fmt$.
'** The backslash is used as an escape char.
'** A backslash followed by a digit string substitutes that arg num.
'** A backslash not followed by digits subs in the next literal char.
'** Arguments:
'** Fmt$ - format string containing instances of \N, N is arg num
'** ArgN$ - string arg to sub in for each instance of \N
'** Returns:
'** Final output string with all arg substitution done.
'** Example:
'** Fmt$ = "\\1 = \1, \\2 = \2, \\3 = \3, \\Z = \Z, \\11 = \11."
'** Out$ = ArgStr$(Fmt$, "Arg1", "Arg2", "", "")
'** REM ...This sets Out$ to "\1 = Arg1, \2 = Arg2, \3 = , \Z = Z, \11 = ."
'*************************************************************************
FUNCTION ArgStr$ (Fmt$, Arg1$, Arg2$, Arg3$, Arg4$) STATIC
rtn$ = Fmt$ 'our returned output string is built here
esc$ = "\" 'this is the esc char we use
i% = 1 'current index into string
WHILE 1
i% = INSTR(i%, rtn$, esc$) 'loc of next esc char
IF i% = 0 THEN
EXIT WHILE 'no more esc chars, quit
END IF
j% = i% + 1
WHILE j% <= LEN(rtn$) AND INSTR("0123456789", MID$(rtn$, j%, 1)) <> 0
j% = j% + 1
WEND 'i%+1 is start of number string, j% is end+1
IF j% = i% + 1 THEN 'digit string empty, drop esc char and take next char as literal
rtn$ = MID$(rtn$, 1, i% - 1) + MID$(rtn$, j%)
i% = i% + 1 'next search pos in string
ELSE 'digit string non-empty, read int and sub in arg
num% = VAL(MID$(rtn$, i% + 1, j% - i% - 1))
SELECT CASE num%
CASE 1
Arg$ = Arg1$
CASE 2
Arg$ = Arg2$
CASE 3
Arg$ = Arg3$
CASE 4
Arg$ = Arg4$
CASE ELSE
Arg$ = ""
END SELECT
rtn$ = MID$(rtn$, 1, i% - 1) + Arg$ + MID$(rtn$, j%)
i% = i% + LEN(Arg$) 'next search pos in string
END IF
WEND
ArgStr$ = rtn$
END FUNCTION