home *** CD-ROM | disk | FTP | other *** search
- '*****************************************************************************
- '* Corners Setup Program
- '*****************************************************************************
-
- '**'$DEFINE DEBUG
- '** '$DEFINE SETUP_3M ''Define for the 3M version of the setup script
-
-
- '$INCLUDE 'setupapi.inc'
- '$INCLUDE 'msdetect.inc'
-
- '** Dialog ID's
- '*****************************************************************************
- CONST WELCOME = 100
- CONST ASKQUIT = 200
- CONST DESTPATH = 300
- CONST EXITFAILURE = 400
- CONST EXITQUIT = 600
- CONST EXITSUCCESS = 700
- CONST OPTIONS = 800
- CONST APPHELP = 900
- CONST TOOBIG = 6300
- CONST BADPATH = 6400
- CONST CDALREADYUSED = 7100
- CONST CDCONFIRMINFO = 7300
- CONST CDGETNAMEORG = 7500
-
- CONST DESTPATHHELP = 10000
- CONST WRONGVER = 10400
-
-
- '** Symbol table identifiers and other goodies
- '*****************************************************************************
- CONST SW_SHOWNORMAL = 1
- CONST RT_STRING = 6
- CONST SEM_NOOPENFILEERRORBOX = &H8000 '** 0x8000
-
- CONST ID_USERNAME = 200
- CONST ID_USERORG = 201
- CONST ID_NUMBER = 202
-
- CONST DEFAULTDEST$ = "C:\CORNWIN"
- CONST FRAMETITLE$ = "Corners Installation Program"
-
- CONST APPEXE$ = "AppEXE"
- CONST APPDLL$ = "AppDLL"
- CONST INIFILE$ = "INI"
- CONST SYSFILES$ = "SystemFiles"
-
- CONST README$ = "ReadMe"
- CONST VIEWAPP$ = "write.exe"
-
- CONST PROGMANGRPNAME$ = "Gamos"
- CONST APPLICATION$ = "Application"
- CONST APPITEMNAME$ = "Corners"
-
-
- '** This string also exists in the dialog box code. If you change it
- '** here, change it there too.
- '*************************************************************************
- CONST DESTDIRNAME$ = "destdirname"
-
-
- '** Bitmap IDs
- '*****************************************************************************
- CONST LOGO = 1
- CONST APPLOGO = 2
-
-
- '** Global variable declarations
- '*****************************************************************************
- GLOBAL dest$ '' Default destination directory.
- GLOBAL username$ '' User name (required)
- GLOBAL userorg$ '' User organization (optional)
- GLOBAL definst$ '' "1" iff default installation
- GLOBAL stamped% '' has username/org been stamped ?
- GLOBAL srcdir$ '' directory where setup is run from
- GLOBAL serialno$ '' serial number
-
-
- '** Function/subroutine declarations.
- '*****************************************************************************
- DECLARE SUB LibInitialize LIB "mscuistf.dll" (hwnd%, id%)
- DECLARE SUB LibTerminate LIB "mscuistf.dll"
- DECLARE FUNCTION DWListInit LIB "mscuistf.dll" (listlen%) AS INTEGER
- DECLARE SUB DWListTerm LIB "mscuistf.dll"
- DECLARE SUB DWListAddItem LIB "mscuistf.dll" (item%, itemval&)
- DECLARE SUB DWListSetBase LIB "mscuistf.dll" (baseval&)
- DECLARE FUNCTION IsALConflict LIB "mscuistf.dll" (thestr$) AS INTEGER
- DECLARE SUB FixALConflict LIB "mscuistf.dll" (thestr$)
- DECLARE SUB DeleteExeName LIB "mscuistf.dll" (thestr$, exename$)
- DECLARE FUNCTION GetNameOrg LIB "mscuistf.dll" AS INTEGER
- DECLARE SUB PrependToAutoExec LIB "mscuistf.dll" (filename$, strdata$, datalen%)
-
- DECLARE SUB ReplaceResString LIB "mscuistf.dll" (filename$, id%, new$)
-
- DECLARE FUNCTION SetErrorMode LIB "kernel" (newmode%) AS INTEGER
- DECLARE SUB WinExec LIB "kernel" (cmdline$, cmdshow%)
-
- DECLARE FUNCTION GetSizeofSectionFiles (szSect$) AS LONG
- DECLARE FUNCTION GetAutoExecName () AS STRING
- DECLARE FUNCTION DoesInfSectionExist (szsect$) AS INTEGER
- DECLARE SUB Install
- DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
-
-
- INIT:
- CUIDLL$ = "mscuistf.dll" ''Custom user interface dll
- HELPPROC$ = "FHelpDlgProc" ''Help dialog procedure
-
- '** Set the frame window bitmap and title.
- '*************************************************************************
- LibInitialize HwndFrame(), APPLOGO
- SetBitmap CUIDLL$, LOGO
- SetTitle FRAMETITLE$
-
- '** Get the full path spec for the .INF file.
- '*************************************************************************
- szInf$ = GetSymbolValue("STF_SRCINFPATH")
- IF srcdir$ = "" THEN
- szInf$ = GetSymbolValue("STF_CWDDIR") + "SETUP.INF"
- END IF
- ReadInfFile szInf$
-
- '** Initialize global variables
- '*************************************************************************
- dest$ = DEFAULTDEST
- username$ = ""
- userorg$ = ""
- fix_al% = 0
- definst$ = "1"
- stamped% = 0
- srcdir$ = GetSymbolValue("STF_SRCDIR")
- serialno$ = "beta 021695"
-
- '$IFDEF DEBUG
- i% = SetSizeCheckMode(scmOnIgnore) '' could use scmOff; def = scmOnFatal
- WinDrive$ = MID$(GetWindowsDir, 1, 1)
- IF IsDriveValid(WinDrive$) = 0 THEN
- i% = DoMsgBox("Windows drive ('"+WinDrive$+"') is not a valid drive.", "DEBUG", MB_TASKMODAL+MB_ICONHAND+MB_OK)
- GOTO QUIT
- END IF
- '$ENDIF ''DEBUG
-
- '** Verify that we are installing in at least Windows 3.1. This puppy
- '** doesn't support 3.0.
- '*************************************************************************
- IF (GetWindowsMajorVersion() = 3) AND (GetWindowsMinorVersion() < 10) THEN
- WRONGVERSION:
- sz$ = UIStartDlg(CUIDLL$, WRONGVER, "FInfoDlgProc", 0, "")
-
- IF sz$ = "REACTIVATE" THEN
- GOTO WRONGVERSION
- END IF
-
- UIPopAll
- ERROR STFQUIT
- END IF
-
-
- '** Show the Welcome dialog box. The ASKQUIT subroutine will query the
- '** user if they want to quit. If they really do quit, run-time error
- '** STF_QUIT occurs and execution resumes at the "QUIT:" label.
- '**
- '** The 3M version of the script does not include the custom/default
- '** installation option. Since definst$ = "1" initially, and never gets
- '** changed, the 3M version always uses the default installation.
- '*************************************************************************
- SetSymbolValue "RadioDefault", "1"
-
- WELCOME:
- sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", 0, "")
-
- IF sz$ = "CONTINUE" THEN
- UIPop 1
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO WELCOME
- ELSE
- GOSUB ASKQUIT
- GOTO WELCOME
- END IF
-
-
- '** Get the User name and User organization strings.
- '*************************************************************************
- ' sz$ = MakePath(srcdir$, "SETUP.INI")
-
- ' IF DoesIniKeyExist(sz$, "UserInfo", "UserName") > 0 THEN
- '** Product has already been installed once. Give the "you're a
- '** potentially baaaad user message" and retrieve the strings.
- '*********************************************************************
- ' username$ = GetIniKeyString(sz$, "UserInfo", "UserName")
- ' userorg$ = GetIniKeyString(sz$, "UserInfo", "UserOrg")
- ' stamped% = 1
-
- ' SetSymbolValue "ConfirmTextIn", ""
- ' AddListItem "ConfirmTextIn", username$
- ' AddListItem "ConfirmTextIn", userorg$
-
- ' ALREADYUSED:
- ' sz$ = UIStartDlg(CUIDLL$, CDALREADYUSED, "FConfirmDlgProc", 0, "")
-
- ' IF sz$ = "CONTINUE" THEN
- ' UIPop 1
- ' ELSEIF sz$ = "REACTIVATE" THEN
- ' GOTO ALREADYUSED
- ' ELSE
- ' UIPopAll
- ' GOTO EXITSCRIPT
- ' END IF
- ' ELSE
- '** Get the user Name/Organization. Returned symbols are:
- '** "NameOut" - the user's name.
- '** "OrgOut" - the user's organization (if any).
- '*********************************************************************
- ' GETNAMEORG:
- ' sz$ = UIStartDlg(CUIDLL$, CDGETNAMEORG, "FNameOrgDlgProc", 0, "")
- ' username$ = GetSymbolValue("NameOut")
- ' userorg$ = GetSymbolValue("OrgOut")
- ' stamped% = 0
-
- ' IF sz$ = "CONTINUE" THEN
- '** Confirm what they told us. Empty the list before inserting the
- '** names into it.
- '*****************************************************************
- ' SetSymbolValue "ConfirmTextIn", ""
- ' AddListItem "ConfirmTextIn", username$
- ' AddListItem "ConfirmTextIn", userorg$
- ' sz$ = UIStartDlg(CUIDLL$, CDCONFIRMINFO, "FConfirmDlgProc", 0, "")
- '
- ' if sz$ = "CONTINUE" THEN
- ' UIPop(2)
- ' ELSE
- ' UIPop(1)
- ' GOTO GETNAMEORG
- ' END IF
- ' ELSEIF sz$ = "REACTIVATE" THEN
- ' GOTO GETNAMEORG
- ' ELSE
- ' GOSUB ASKQUIT
- ' GOTO GETNAMEORG
- ' END IF
- ' END IF
-
- ' SetSymbolValue "ConfirmTextIn", ""
- ' SetSymbolValue "NameOut", ""
- ' SetSymbolValue "OrgOut", ""
-
-
- '** Get the destination pathname.
- '*************************************************************************
- GETPATH:
- SetSymbolValue "EditTextIn", dest$
- SetSymbolValue "EditFocus", "ALL"
-
- GETPATHL1:
- sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", DESTPATHHELP, HELPPROC$)
- dest$ = GetSymbolValue("EditTextOut")
-
- IF sz$ = "CONTINUE" THEN
- IF IsDirWritable(dest$) = 0 THEN
- GOSUB BADPATH
- GOTO GETPATHL1
- END IF
- UIPop 1
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO GETPATHL1
- ELSE
- GOSUB ASKQUIT
- GOTO GETPATH
- END IF
-
-
- '** Finally - do the install.
- '*************************************************************************
- Install
-
-
- QUIT:
- ON ERROR GOTO ERRQUIT
-
- IF ERR = 0 THEN
- EXIT_SUCCESS:
- '** Successfull install. At exit allow the user the chance to
- '** run the program.
- '*********************************************************************
- sz$ = UIStartDlg(CUIDLL$, EXITSUCCESS, "FInfo0DlgProc", 0, "")
- runapp$ = GetSymbolValue("DLGEVENT")
-
- IF sz$ = "REACTIVATE" THEN
- GOTO EXIT_SUCCESS
- END IF
- UIPop 1
-
- IF runapp$ = "RUN" THEN
- runapp$ = VIEWAPP$ + " " + MakePath(dest$, GetSectionKeyFilename(APPDLL$, README$))
-
- '$IFDEF DEBUG
- OpenLogFile MakePath(dest$, "LOGFILE.TXT"), 1
- WriteToLogFile "Running: " + runapp$ + "."
- CloseLogFile
- '$ENDIF ''DEBUG
-
- errmode% = SetErrorMode(SEM_NOOPENFILEERRORBOX)
- WinExec runapp$, SW_SHOWNORMAL
- errmode% = SetErrorMode(errmode%)
- END IF
- ELSEIF (ERR = STFQUIT) OR (ERR = STFERR) THEN
- dlg% = 0
- ELSE
- EXIT_FAIL:
- '** Unsuccessfull installation.
- '*********************************************************************
- sz$ = UIStartDlg(CUIDLL$, EXITFAILURE, "FInfo0DlgProc", 0, "")
-
- IF sz$ = "REACTIVATE" THEN
- GOTO EXIT_FAIL
- END IF
- UIPop 1
- END IF
-
- EXITSCRIPT:
- LibTerminate
- END
-
- ERRQUIT:
- LibTerminate
-
- '$IFDEF DEBUG
- OpenLogFile MakePath(dest$, "LOGFILE.TXT"), 1
- WriteToLogFile "ERRQUIT: error = " + STR$(ERR) + "."
- CloseLogFile
- '$ENDIF ''DEBUG
-
- i% = DoMsgBox("An unknown error has occurred.\nPlease contact Alex Software.", "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
- END
-
-
-
- '** Subroutine BADPATH
- '**
- '** Simply notifies the user that the path they specified is bogus, and
- '** then returns.
- '**
- '*****************************************************************************
- BADPATH:
- DIM MSGTEXT1$
- DIM MSGTEXT2$
-
- MSGTEXT1$ = "The path you specified is invalid. Please re-enter the path for "
- MSGTEXT2$ = "installation, or cancel Setup and check your computer's configuration."
- i% = DoMsgBox(MSGTEXT1$ + MSGTEXT2$, "Setup Message", MB_OK+MB_TASKMODAL+MB_ICONHAND)
- RETURN
-
-
-
- '** Subroutine ASKQUIT
- '**
- '** Querys the user in a "do you really, really want to quit ?" fashion.
- '** If they do, ERROR STFQUIT occurs. Otherwise, the subroutine returns.
- '**
- '*****************************************************************************
- 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
-
-
- '** Function GetSizeofSectionFiles
- '**
- '** Determines the size of all files contained in a given section.
- '**
- '*****************************************************************************
- FUNCTION GetSizeofSectionFiles (szSect$) STATIC AS LONG
- MakeListFromSectionKeys "__get_list", szSect$
- listlen% = GetListLength("__get_list")
- sectsize& = 0
-
- FOR i% = 1 TO listlen% STEP 1
- sz$ = GetListItem("__get_list", i%)
- sectsize& = sectsize& + GetSectionKeySize(szSect$, sz$)
- NEXT
-
- SetSymbolValue "__get_list", ""
- GetSizeofSectionFiles = sectsize&
- END FUNCTION
-
-
-
- '** Function DoesInfSectionExist
- '**
- '** Determines if the specified INF file section exists. This is necessary
- '** since some of setup functions die if the section does not exist.
- '**
- '*****************************************************************************
- FUNCTION DoesInfSectionExist (szsect$) STATIC AS INTEGER
- MakeListFromSectionKeys "__test_list", szsect$
- listlen% = GetListLength("__test_list")
- SetSymbolValue "__test_list", ""
-
- DoesInfSectionExist = listlen%
- END FUNCTION
-
-
- '**
- '** Purpose:
- '** Builds the copy list and performs all installation operations.
- '** Arguments:
- '** none.
- '** Returns:
- '** none.
- '*****************************************************************************
- SUB Install STATIC
- '** Stamp SETUP.INI with the user name and organization.
- '*************************************************************************
- ' IF stamped% = 0 THEN
- ' sz$ = MakePath(srcdir$, "SETUP.INI")
-
- ' IF IsFileWritable(sz$) = 1 THEN
- ' CreateIniKeyValue sz$, "UserInfo", "UserName", username$, cmoNone
- ' CreateIniKeyValue sz$, "UserInfo", "UserOrg", userorg, cmoNone
- ' END IF
- ' END IF
-
-
- '** Create the destination directory.
- '*************************************************************************
- CreateDir dest$, cmoNone
-
- '$IFDEF DEBUG
- OpenLogFile MakePath(dest$, "LOGFILE.TXT"), 0
- WriteToLogFile ""
- WriteToLogFile " User chose as destination directory: '" + dest$ + "'"
- WriteToLogFile " Source directory: '" + srcdir$ + "'"
- WriteToLogFile ""
- WriteToLogFile "May have had to create the directory: " + dest$
- WriteToLogFile ""
- '$ENDIF ''DEBUG
-
-
- '** Build the copy list and copy the files.
- '*************************************************************************
- AddSectionFilesToCopyList APPEXE$, srcdir$, dest$
- AddSectionFilesToCopyList APPDLL$, srcdir$, dest$
-
-
- '** Add the screen saver SCR file to the copylist only in Windows
- '** version 3.1 and newer, and -not- for the 3M version.
- '*************************************************************************
- '$IFNDEF SETUP_3M
- IF (GetWindowsMajorVersion() > 3) OR (GetWindowsMinorVersion() >= 10) THEN
- sz$ = GetSectionKeyFilename(SYSFILES$, "BWCC")
- sz$ = MakePath(GetWindowsSysDir(), sz$)
- AddSpecialFileToCopyList SYSFILES$, "BWCC", srcdir$, sz$
- END IF
- '$ENDIF ''SETUP_3M
-
- '$IFDEF DEBUG
- '** mode% = SetCopyMode(0) '** disables actual copy
- DumpCopyList MakePath(dest$, "copylist.txt")
- '$ENDIF ''DEBUG
-
- '** Verify that the user has enough space to copy all files in the copy
- '** list. If not, just let them know and terminate the installation.
- '*************************************************************************
- needed& = GetCopyListCost("", "", "")
-
- IF needed& > 0 THEN
- NEEDSPACE:
- sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "")
-
- IF sz$ = "REACTIVATE" THEN
- GOTO NEEDSPACE
- ELSE
- UIPopAll
- ERROR STFQUIT
- END IF
- END IF
-
-
- '** OK, now really copy the files.
- '*************************************************************************
- CopyFilesInCopyList
-
-
- '** Stamp the EXE with the username and org.
- '*************************************************************************
- ' sz$ = MakePath(dest$, GetSectionKeyFilename(APPEXE$, APPLICATION$))
- ' ReplaceResString sz$, ID_USERNAME, username$
- ' ReplaceResString sz$, ID_USERORG, userorg$
- ' ReplaceResString sz$, ID_NUMBER, serialno$
-
-
- '** Stamp INIFILE with the user name and organization.
- '*************************************************************************
- ' sz$ = MakePath(dest$, GetSectionKeyFilename(APPDLL$, INIFILE$))
- ' CreateIniKeyValue sz$, "User", "User", username$, cmoNone
- ' CreateIniKeyValue sz$, "User", "Organization", userorg, cmoNone
-
-
- CreateProgmanGroup PROGMANGRPNAME$, "", cmoNone
- ShowProgmanGroup PROGMANGRPNAME$, 1, cmoNone
- CreateProgmanItem PROGMANGRPNAME$, APPITEMNAME$, MakePath(dest$, GetSectionKeyFilename(APPEXE$, APPLICATION$)), "", cmoOverwrite
-
- '$IFDEF DEBUG
- CloseLogFile
- '$ENDIF ''DEBUG
-
- 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
-