'************************************************************************** '* ArcView OEM Setup script '************************************************************************** 'If we want to strip off a switch, we have to do it before the rest of setup initializes GLOBAL isDebug% GLOBAL isForced% DECLARE FUNCTION CommandLine(c$) AS INTEGER isDebug% = CommandLine("d") isForced% = CommandLine("f") COMMAND$ = RTRIM$(COMMAND$) '$INCLUDE 'setupapi.inc' '$INCLUDE 'msdetect.inc' ''Dialog ID's Const WELCOME = 100 Const ARCVIEWOPTIONS = 2100 Const ASKQUIT = 200 Const TOOBIG = 6300 Const BADPATH = 6400 Const MODIFYCONFIGSYS = 1800 Const ARCVIEWPATH = 1500 Const AVDATAPATH = 2300 Const EXITQUIT = 600 Const EXITFAILURE = 400 Const EXITFAILNOTWIN31 = 1200 Const EXITFAILNOTENH = 1300 Const EXITFAILNOTINTEL = 1350 Const EXITFAILNOMEMORY = 1375 Const EXITFAILNOTRUETYPE = 1380 Const EXITSUCCESS = 700 Const EXITSUCCESSWITHINFO = 750 Const EXITSUCCESSNT = 2600 CONST LOGO = 1 CONST AVMINSWAP = 12000 CONST AVMINRAM = 7200 CONST ENOUGHFILES = 65 CONST BOOL_TRUE = -1 CONST BOOL_FALSE = 0 CONST KIT_TRUE = 1 CONST KIT_FALSE = 0 CONST EXT_NONEED = 0 'Don't need windows extension CONST EXT_NEED = 1 'Need windows extension CONST EXT_START = 2 'Need to start windows extension CONST MB_ICONINFORMATION = 64 Const szNewVer$ = "1.25.141.0" 'Version of Win32s we are installing TYPE TMEMMANINFO 'From Windows SDK Size AS LONG LargestFreeBlock AS LONG MaxPagesAvailable AS LONG MaxPagesLockable AS LONG TotalLinearSpace AS LONG TotalUnlockedPages AS LONG FreePages AS LONG TotalPages AS LONG FreeLinearSpace AS LONG SwapFilePages AS LONG PageSize as INTEGER END TYPE TYPE TRASTERIZERSTATUS 'From Windows SDK nSize AS INTEGER wFlags AS INTEGER nLanguageID AS INTEGER END TYPE CONST TT_FLAGS = 3 GLOBAL DESTSYS$ ''Windows\System directory. GLOBAL DESTSYS32$ ''Windows\System32 directory. GLOBAL DEST32S$ ''Windows\System\Win32s directory GLOBAL DESTAV$ ''ArcView directory GLOBAL DESTAVDATA$ ''ArcView data directory GLOBAL CUIDLL$ ''User Interface DLL GLOBAL eol$ GLOBAL endmsg$ GLOBAL SrcDir$ GLOBAL IniFileName$ GLOBAL ProductName$ GLOBAL CompanyName$ GLOBAL OnWin32% GLOBAL addvshare$ GLOBAL NeedWin32s% GLOBAL WantArcView% GLOBAL WantData% GLOBAL CommandToRun$ DECLARE FUNCTION IsMachineOK AS INTEGER DECLARE FUNCTION IsShareOK AS INTEGER DECLARE FUNCTION IsMemoryOK AS INTEGER DECLARE SUB IsFontsOK DECLARE SUB PrepareWin32s DECLARE SUB Prepare2Win32s DECLARE SUB CleanUpWin32s DECLARE SUB PrepareVShare DECLARE SUB CleanUpVShare DECLARE SUB PrepareWINSOCKStub DECLARE SUB PrepareWSOCK32Stub DECLARE SUB PrepareSysArcView DECLARE SUB ConfirmArcView DECLARE SUB CleanUpArcView DECLARE SUB ConfirmData DECLARE SUB CopyArcView DECLARE SUB CopyData DECLARE SUB ShowMyMessage(dlg%) DECLARE SUB AddDebugString(s$) DECLARE SUB AddBoolDebugString(s$,b%) DECLARE SUB RebootSystem DECLARE FUNCTION AVModifyFile(msgdlg%, fn$, detline$, addline$) AS INTEGER DECLARE FUNCTION GetNewFileName(szFile$, szExt$) AS STRING DECLARE FUNCTION CompareVersions(szfirst$, szsecond$) AS INTEGER DECLARE FUNCTION ConfirmPath(szPath$, dlg%) AS STRING DECLARE FUNCTION MakeSystemIni LIB "INIUPD.DLL" (arg1$, arg2$, arg3$) AS INTEGER DECLARE FUNCTION RestartWindows LIB "INIUPD.DLL" AS INTEGER DECLARE FUNCTION OnWindowsNT LIB "INIUPD.DLL" AS INTEGER DECLARE FUNCTION PagingEnabled LIB "INIUPD.DLL" AS INTEGER DECLARE FUNCTION ShareEnabled LIB "INIUPD.DLL" AS INTEGER DECLARE FUNCTION IsWin32sLoaded LIB "INIUPD.DLL" (arg1$) AS INTEGER DECLARE FUNCTION GetInstalledRAM LIB "INIUPD.DLL" AS LONG DECLARE FUNCTION ExitWindowsExec LIB "USER.EXE" (arg1$, arg2$) AS INTEGER DECLARE FUNCTION MemManInfo LIB "TOOLHELP.DLL" (arg1 AS POINTER TO TMEMMANINFO) AS INTEGER DECLARE FUNCTION GetRasterizerCaps LIB "GDI.EXE" (lpraststat AS POINTER TO TRASTERIZERSTATUS, cb AS INTEGER) AS INTEGER eol$ = CHR$(10) + CHR$(13) + CHR$(10) + CHR$(13) INIT: addvshare$ = "" CUIDLL$ = "mscuistf.dll" ''Custom user interface dll ON ERROR GOTO ERRNORMAL IF isDebug% THEN i% = DoMsgBox("You are running setup in debug mode. Setup results will be written to C:\AVSETUP.TXT","", MB_ICONEXCLAMATION+MB_OK+MB_TASKMODAL) OpenLogFile "C:\AVSETUP.TXT", KIT_FALSE WriteToLogFile "ArcView 2.1 OEM setup debug mode results" END IF SrcDir$ = GetSymbolValue("STF_SRCDIR") szInf$ = GetSymbolValue("STF_SRCINFPATH") IF szInf$ = "" THEN szInf$ = GetSymbolValue("STF_CWDDIR") + "AVLOCK.INF" END IF ReadInfFile szInf$ AddDebugString "Read .INF file: " + szInf$ DESTAV$ = SrcDir$ + "PROGRAM\" DESTAVDATA$ = SrcDir$ + "DATA\" DESTSYS$ = GetWindowsSysDir() DEST32S$ = DESTSYS + "WIN32S\" DESTWIN$ = GetWindowsDir() IF DoesDirExist(DESTWIN$ + "SYSTEM32") = KIT_TRUE THEN DESTSYS32$ = DESTWIN$ + "SYSTEM32\" ELSE DESTSYS32$ = DESTSYS$ END IF AddDebugString "Found Windows system directory: " + DESTSYS$ AddBoolDebugString "Windows system directory writable: ", IsDirWritable(DESTSYS$) AddDebugString "Found Windows system32 directory: " + DESTSYS$ AddBoolDebugString "Windows system32 directory writable: ", IsDirWritable(DESTSYS32$) IniFileName$ = SrcDir$ + "AVLOCK.INI" ProductName$ = GetIniKeyString (IniFileName$, "ArcView", "Name") AddDebugString "AV OEM Product Name: " + ProductName$ SetSymbolValue "ProductName", ProductName$ SetTitle ProductName$ CompanyName$ = GetIniKeyString (IniFileName$, "ArcView", "Company") AddDebugString "AV OEM Company Name: " + CompanyName$ SetSymbolValue "CompanyName", CompanyName$ DataName$ = GetIniKeyString (IniFileName$, "Data", "Name") AddDebugString "AV OEM Data Name: " + DataName$ SetSymbolValue "DataName", DataName$ NeedWin32s% = IsMachineOK() IsFontsOK ShareOK% = IsShareOK() MemoryOK% = IsMemoryOK() AddDebugString "FILES=:"+STR$(GetConfigNumFiles()) HasWSOCK32% = (DoesFileExist(DESTSYS32$+"WSOCK32.DLL", femExists) = KIT_TRUE) AddBoolDebugString "WSOCK32.DLL exists: ",HasWSOCK32% HasWSOCK32% = HasWSOCK32% OR (NOT OnWin32%) 'If not NT, then get WSOCK32 as part of Win32s dfe5$ = FindFileUsingFileOpen("WINSOCK.DLL") HasWINSOCK% = (dfe5$ <> "") AddBoolDebugString "WINSOCK.DLL exists: ",HasWINSOCK% AddDebugString "WINSOCK.DLL is at: "+dfe5$ AllowArcViewCopy% = (GetIniKeyString (IniFileName$, "ArcView", "AllowCopy") = "1") AddBoolDebugString "Allowed to copy ArcView: ", AllowArcViewCopy% AllowDataCopy% = (GetIniKeyString (IniFileName$, "Data", "AllowCopy") = "1") AddBoolDebugString "Allowed to copy data: ", AllowDataCopy% WELCOME: sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", 0, "") IF sz$ = "CONTINUE" THEN UIPop 1 ELSE GOSUB ASKQUIT GOTO WELCOME END IF SetSymbolValue "OptionsInvisible", "" IF NOT AllowArcViewCopy% THEN AddListItem "OptionsInvisible", "1" END IF IF NOT AllowDataCopy% THEN AddListItem "OptionsInvisible", "2" END IF SetSymbolValue "OptionNames", "" AddListItem "OptionNames", ProductName$ AddListItem "OptionNames", DataName$ CHOICES: sz$ = UIStartDlg(CUIDLL$, ARCVIEWOPTIONS, "FCheckDlgProc", 100, "") IF sz$ = "CONTINUE" THEN UIPop 1 ELSE GOSUB ASKQUIT GOTO CHOICES END IF WantArcView% = (GetListItem("CheckItemsOut",1)="ON") AddBoolDebugString "User checked ArcView box:", WantArcView WantData% = (GetListItem("CheckItemsOut",2)="ON") AddBoolDebugString "User checked data box:", WantData% IF WantArcView% THEN ConfirmArcView END IF IF WantData% THEN ConfirmData END IF ClearCopyList IF NeedWin32s% = EXT_NEED THEN PrepareWin32s END IF IF ShareOK% = EXT_NEED THEN PrepareVShare END IF PrepareSysArcView IF NOT HasWINSOCK% THEN PrepareWINSOCKStub END IF IF NOT HasWSOCK32% THEN PrepareWSOCK32Stub END IF FOR ii = 1 TO 26 AddListItem "AV_EXTRA","0" NEXT ii IF NeedWin32s% <> EXT_NONEED THEN ReplaceListItem "AV_EXTRA", (ASC(MID$(DESTSYS$,1,1))-ASC("A")+1),"1000" END IF IF WantArcView% THEN item% = (ASC(MID$(DESTAV$,1,1))-ASC("A")+1) size% = VAL(GetIniKeyString (IniFileName$, "ArcView", "Size")) AddDebugString "Size of ArcView: "+STR$(size%) ReplaceListItem "AV_EXTRA", item%, STR$(VAL(GetListItem("AV_EXTRA", item%)) + size%) END IF IF WantData% THEN item% = (ASC(MID$(DESTAVDATA$,1,1))-ASC("A")+1) size% = VAL(GetIniKeyString (IniFileName$, "Data", "Size")) AddDebugString "Size of Data: "+STR$(size%) ReplaceListItem "AV_EXTRA", item%, STR$(VAL(GetListItem("AV_EXTRA", item%)) + size%) END IF spaceneeded = GetCopyListCost("AV_EXTRA","AV_COST","AV_NEEDED") AddDebugString "Disk space needed:"+STR$(spaceneeded) IF spaceneeded > 0 THEN ShowMyMessage TOOBIG ClearCopyList GOTO CHOICES END IF IF NeedWin32s% = EXT_NEED THEN Prepare2Win32s END IF IF (NeedWin32s% <> EXT_NONEED) OR (ShareOK% <> EXT_NONEED) THEN SetRestartDir GetWindowsDir() END IF CopyFilesInCopyList IF WantArcView% THEN CopyArcView END IF IF WantData% THEN CopyData END IF IF ERR <> 0 THEN GOTO QUIT END IF endmsg$ = "" IF ShareOK% <> EXT_NONEED THEN CleanUpVShare END IF IF NeedWin32s% <> EXT_NONEED THEN CleanUpWin32s ELSEIF addvshare$ <> "" THEN CreateSysIniKeyValue GetWindowsDir() + "SYSTEM.INI", "386Enh", "device", addvshare$, cmoNone END IF CleanUpArcView QUIT: '' Install error handler for final message box routines ON ERROR GOTO ERRQUIT IF ERR = 0 THEN ExitCode% = EXITSUCCESS ELSEIF ERR = STFQUIT THEN ExitCode% = EXITQUIT ELSEIF (ERR = EXITFAILNOTWIN31) OR (ERR = EXITFAILNOTENH) OR (ERR = EXITFAILNOTINTEL) OR (ERR = EXITFAILNOMEMORY) OR (ERR = EXITFAILNOSHARE) OR (ERR = EXITFAILNOTRUETYPE) THEN ExitCode% = ERR ELSE ExitCode% = EXITFAILURE END IF ExitDlgProc$ = "FInfo0DlgProc" IF ExitCode% = EXITSUCCESS THEN IF NOT MemoryOK% THEN endmsg$ = endmsg$ + "Please configure Windows to have at least 12000K of virtual memory with the 386 Enhanced option in the control panel." + eol$ END IF IF LEN(endmsg$)>0 THEN ExitCode% = EXITSUCCESSWITHINFO ExitDlgProc$ = "FInfo1DlgProc" SetSymbolValue "ExitInfoIn", endmsg$ ELSEIF (NeedWin32s% = EXT_NONEED) AND (ShareOK% = EXT_NONEED) THEN ExitCode% = EXITSUCCESSNT END IF END IF QUITL1: sz$ = UIStartDlg(CUIDLL$, ExitCode%, ExitDlgProc$, 0, "") IF sz$ = "REACTIVATE" THEN GOTO QUITL1 END IF UIPop 1 IF isDebug% THEN WriteToLogFile "End of ArcView 2.1 OEM setup debug mode results" CloseLogFile END IF IF (ExitCode% = EXITSUCCESS) OR (ExitCode% = EXITSUCCESSWITHINFO) THEN RebootSystem CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite i% = DoMsgBox(ProductName$ + " is not properly configured and Setup must be run again.", "Unable to Restart Windows", MB_ICONEXCLAMATION+MB_OK+MB_TASKMODAL) END IF END '' Fatal error handler for error message routine ERRQUIT: i% = DoMsgBox("ERR="+STR$(ERR)+"ERL="+STR$(ERL), "Setup", MB_OK+MB_TASKMODAL+MB_ICONHAND) END '' Bypass run-time errors. Let final dialog box display fatal error message. ERRNORMAL: IF (ERR = STFQUIT) OR (((ERR = EXITFAILNOTWIN31) OR (ERR = EXITFAILNOTENH) OR (ERR = EXITFAILNOTINTEL) OR (ERR = EXITFAILNOMEMORY) OR (ERR = EXITFAILNOSHARE) OR (ERR = EXITFAILNOTRUETYPE)) AND (NOT isForced%)) THEN GOTO QUIT END IF IF isForced% THEN ERR = 0 END IF IF (ERR = 14) AND (CommandToCopy$ <> "") THEN 'Illegal Function call in RUN i% = DoMsgBox("Setup could not use XCOPY to copy files to your hard drive. Please run " + CommandToCopy$ +" at the DOS prompt to complete installation.","", MB_ICONEXCLAMATION+MB_OK+MB_TASKMODAL) ERR = 0 END IF RESUME NEXT 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: '** Reboots Windows to patch system files if necessary. '************************************************************************** SUB RebootSystem STATIC IF RestartListEmpty() = KIT_FALSE THEN i% = ExitExecRestart() ELSE i% = ExitWindowsExec(GetWindowsDir() + "_MSRSTRT.EXE", "_MSSETUP.BAT") END IF END SUB '** Purpose: '** Checks if machine can run Win32s applications with Win32s for Win3.1 if necessary. '** Returns: '** Causes error if machine can't run Win32s applications at all. '** Returns EXT_NONEED if machine doesn't need Win32s. '** Returns EXT_NEED if machine does need Win32s. '** Returns EXT_START if machine needs Win32s started. '************************************************************************** FUNCTION IsMachineOK STATIC AS INTEGER OnWin32% = BOOL_FALSE NeedIt% = EXT_NEED winmajor% = GetWindowsMajorVersion AddDebugString "Windows Major Version:"+STR$(winmajor%) winminor% = GetWindowsMinorVersion AddDebugString "Windows Major Version:"+STR$(winminor%) IF winmajor% < 3 THEN ERROR EXITFAILNOTWIN31 END IF IF winmajor% = 3 AND winminor% < 10 THEN ERROR EXITFAILNOTWIN31 END IF 'Note: Chicago is Windows 3.95, not 4.0 IF (winmajor% >= 4) OR (winmajor% = 3 AND winminor% > 50) THEN AddDebugString "Installing on Win95 or later" OnWin32% = BOOL_TRUE NeedIt% = EXT_NONEED GOTO MACHINEOK END IF AddDebugString "Windows Mode:"+STR$(GetWindowsMode) IF GetWindowsMode < 2 THEN IF OnWin32% THEN AddDebugString "Installing on Windows NT on RISC" ERROR EXITFAILNOTINTEL '' Windows NT on RISC ELSE AddDebugString "Installing in Standard Mode" ERROR EXITFAILNOTENH '' Standard Mode Windows END IF END IF IF (OnWindowsNT() <> KIT_FALSE) THEN AddDebugString "Installing on Windows NT" OnWin32% = BOOL_TRUE NeedIt% = EXT_NONEED GOTO MACHINEOK END IF 'At this point, we are on Win3.1 enhanced mode IF GetIniKeyString (DESTSYS$ + "WIN32S.INI", "Win32s", "Setup") <> "1" THEN AddDebugString "WIN32S.INI shows that Win32s was installed earlier but did not succeed" GOTO MACHINEOK END IF dfe% = (DoesFileExist(DESTSYS$ + "W32SYS.DLL", femExists) = KIT_TRUE) AddBoolDebugString "W32SYS.DLL exists: ",dfe% IF NOT dfe% THEN AddDebugString "W32SYS.DLL does not exist" GOTO MACHINEOK END IF szCurver$ = GetVersionOfFile(DESTSYS$ + "WIN32S16.DLL") AddDebugString "Win32s version installed: "+szCurver$ vercomp% = CompareVersions(szCurver$, szNewVer$) IF vercomp% = 2 THEN 'we are out of date GOTO MACHINEOK END IF dde% = (DoesDirExist(DESTSYS$ + "WIN32S") = KIT_TRUE) AddBoolDebugString "WIN32s directory exists: ",dde% IF NOT dde% THEN GOTO MACHINEOK END IF szOldVer$ ="1.00.000 " 'Reserve space in string for version i% = (IsWin32sLoaded(szOldVer$) = KIT_TRUE) AddBoolDebugString "Win32s is loaded: ",i% AddDebugString "Win32s version loaded: "+szOldVer$ IF i% THEN NeedIt% = EXT_NONEED ELSE NeedIt% = EXT_START END IF MACHINEOK: IF NeedIt% = EXT_NONEED THEN AddDebugString "Need Win32s: FALSE" ELSEIF NeedIt% = EXT_NEED THEN AddDebugString "Need Win32s: TRUE" ELSE AddDebugString "Need Win32s: Installed, but not loaded" END IF IsMachineOK = NeedIt% END FUNCTION '** Purpose: '** Checks if machine has TrueType fonts '************************************************************************** SUB IsFontsOK() STATIC DIM TRS AS TRASTERIZERSTATUS ' According to MSDN article with PSS ID Number: Q111586, ' GetRasterizerCaps returns 0 if TrueType is disabled. grc% = GetRasterizerCaps(VARPTR(TRS), 6) AddBoolDebugString "TrueType (GetRasterizerCaps) function working: ",grc% IF grc% = 0 THEN AddDebugString "TrueType is disabled" ERROR EXITFAILNOTRUETYPE ELSE ' But TrueType may be enabled but no fonts installed AddBoolDebugString "TrueType installed: ", (TRS.wFlags = TT_FLAGS) IF (TRS.wFlags AND TT_FLAGS) <> TT_FLAGS THEN AddDebugString "TrueType flags: "+STR$(TRS.wFlags) AddDebugString "TrueType is disabled or not available" ERROR EXITFAILNOTRUETYPE END IF END IF END SUB '** Purpose: '** Checks if machine has enough virtual memory to run ArcView '** Returns: '** Causes error if machine doesn't have virtual memory. Returns TRUE '** if it has enough. Returns FALSE if it needs more. '************************************************************************** FUNCTION IsMemoryOK() STATIC AS INTEGER MemOK% = BOOL_TRUE IF NOT OnWin32% THEN ram& = GetInstalledRAM() AddDebugString "RAM detected (kilobytes):"+STR$(ram&) IF ram& < AVMINRAM THEN ERROR EXITFAILNOMEMORY END IF page% = (PagingEnabled() = KIT_TRUE) AddBoolDebugString "Virtual Memory On: ",page% IF NOT page% THEN ERROR EXITFAILNOMEMORY END IF DIM MMI AS TMEMMANINFO IF MemManInfo(VARPTR(MMI)) <> 0 THEN AddDebugString "Virtual memory detected (kilobytes):"+STR$(MMI.SwapFilePages * MMI.PageSize) IF MMI.SwapFilePages * MMI.PageSize < 1024 * AVMINSWAP THEN MemOK% = BOOL_FALSE END IF END IF END IF IsMemoryOK = MemOK% END FUNCTION '** Purpose: '** Checks if machine has file sharing set up to run ArcView '** Returns: '** Returns EXT_NONEED if machine doesn't need VSHARE. '** Returns EXT_NEED if machine does need VSHARE. '** Returns EXT_START if machine needs VSHARE started. '************************************************************************** FUNCTION IsShareOK() STATIC AS INTEGER ShareOK% = EXT_NONEED IF NOT OnWin32% THEN ShareOK% = EXT_NEED DESTSHARE$ = DESTSYS$ OPEN GetWindowsDir() + "SYSTEM.INI" FOR INPUT AS #1 WHILE (EOF(1) = 0) LINE INPUT #1, lin$ lin$ = UCASE$(RTRIM$(LTRIM$(lin$))) IF (MID$(lin$,1,6) = "DEVICE") AND INSTR(lin$,"VSHARE") THEN ShareOK% = EXT_NONEED END IF WEND CLOSE #1 IF ShareOK% = EXT_NEED THEN IF DoesFileExist(DESTSHARE$ + "VSHARE.386", femExists) = KIT_TRUE THEN ShareOK% = EXT_START END IF END IF END IF IF ShareOK% = EXT_NONEED THEN AddDebugString "Need VShare: FALSE" ELSEIF ShareOK% = EXT_NEED THEN AddDebugString "Need VShare: TRUE" ELSE AddDebugString "Need VShare: Installed, but not loaded" END IF IsShareOK = ShareOK% END FUNCTION '** Purpose: '** Gets a new filename that can be used as scratch/sample file '** Arguments: '** szFile$: First 6 characters of new filename. '** szExt$: Extension of new filename. '** Returns: '** New filename as string. '************************************************************************** FUNCTION GetNewFileName(szFile$, szExt$) STATIC AS STRING n% = 0 TRYFNAGAIN: nfn$ = szFile$+LTRIM$(STR$(n%))+"."+szExt$ IF DoesFileExist(nfn$, femExists) = KIT_TRUE THEN n% = n% + 1 GOTO TRYFNAGAIN END IF GetNewFileName = nfn$ END FUNCTION '** Purpose: '** Cleanly modifies CONFIG.SYS or AUTOEXEC.BAT '** Arguments: '** msgdlg%: Message dialog to explain changes. '** fn$: File to modify (assumed to be in root directory). '** detline$: Line to modify '** addline$: Line to replace it with '** Returns: '** TRUE if the user changed the file, FALSE if they created only a sample '************************************************************************** FUNCTION AVModifyFile(msgdlg%, fn$, detline$, addline$) STATIC AS INTEGER szmodify$ = UIStartDlg(CUIDLL$, msgdlg%, "FInfoDlgProc", 0, "") UIPop 1 comspec$ = GetEnvVariableValue("COMSPEC") IF comspec$ = "" THEN comspec$ = "C:" END IF fullfn$ = MID$(comspec$,1,1)+":\"+fn$ IF DoesFileExist(fullfn$,femExists) = KIT_FALSE THEN i% = DoMsgBox(fn$ + " could not be found. The modifications will not be made.", "Setup", MB_OK+MB_TASKMODAL+MB_ICONINFORMATION) GOTO NOFILE END IF rootfn$ = MID$(comspec$,1,1)+":\"+MID$(fn$,1,6) newfn$ = GetNewFileName(rootfn$,"AVS") didit% = BOOL_FALSE lin$ = "" OPEN fullfn$ FOR INPUT AS #1 OPEN newfn$ FOR OUTPUT AS #2 WHILE (EOF(1) = 0) LINE INPUT #1, lin$ lin2$ = UCASE$(LTRIM$(RTRIM$(lin$))) IF MID$(lin2$,1,3) = "WIN" THEN PRINT #2, addline$ didit% = BOOL_TRUE PRINT #2, lin$ ELSEIF MID$(lin2$,1,LEN(detline$)) = UCASE$(detline$) THEN PRINT #2, addline$ didit% = BOOL_TRUE ELSE PRINT #2, lin$ END IF WEND IF NOT didit% THEN PRINT #2, addline$ END IF CLOSE #1, #2 IF szmodify$ = "CONTINUE" THEN oldfn$ = GetNewFileName(rootfn$,"OLD") soldfn$ = MID$(oldfn$,4,len(oldfn$)-3) RenameFile fullfn$, soldfn$ RenameFile newfn$, fn$ RemoveFile newfn$, cmoForce i% = DoMsgBox("Your original " + fn$ + " has been renamed to " + soldfn$ + ".", "Setup", MB_OK+MB_TASKMODAL+MB_ICONINFORMATION) AVModifyFile = BOOL_TRUE ELSE i% = DoMsgBox("The sample " + fn$ + " is named " + newfn$ + ".", "Setup", MB_OK+MB_TASKMODAL+MB_ICONINFORMATION) AVModifyFile = BOOL_FALSE END IF NOFILE: END FUNCTION '** Purpose: '** Prepares for Win32s install '************************************************************************** SUB PrepareWin32s STATIC AddSectionFilesToCopyList "Win32sSystemObsoleteFiles", SrcDir$, DESTSYS$ + "WIN32S\" AddSectionFilesToCopyList "WindowsSystem", SrcDir$, DESTSYS$ AddSectionFilesToCopyList "WindowsSystemWin32s", SrcDir$, DESTSYS$ + "WIN32S\" END SUB '** Purpose: '** Prepares for Win32s install '************************************************************************** SUB Prepare2Win32s STATIC CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "0", cmoOverwrite CreateDir DEST32S$, cmoNone END SUB '** Purpose: '** Cleans up after Win32s install '************************************************************************** SUB CleanUpWin32s STATIC IF addvshare$ = "" THEN t% = MakeSystemIni(GetWindowsDir(), DEST32S$ + "W32S.386", NULL) ELSE t% = MakeSystemIni(GetWindowsDir(), DEST32S$ + "W32S.386", addvshare$) END IF IF (ERR = 0) AND (NeedWin32s% = EXT_NEED) THEN CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Setup", "1", cmoOverwrite CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Win32s", "Version", szNewVer$, cmoOverwrite CreateIniKeyValue DESTSYS$ + "WIN32S.INI", "Nls", "AnsiCP", "1252", cmoOverwrite END IF END SUB '** Purpose: '** User interface for ArcView install '************************************************************************** SUB ConfirmArcView STATIC ProdPath$ = GetIniKeyString (IniFileName$, "ArcView", "Path") AddDebugString "AV OEM Product Path: " + ProdPath$ DESTAV$ = MID$(DESTSYS$,1,3) + ProdPath$ DESTAV$ = ConfirmPath(DESTAV$, ARCVIEWPATH) END SUB '** Purpose: '** Copies ArcView '************************************************************************** SUB CopyArcView STATIC CommandToCopy$ = "xcopy "+SrcDir$+"PROGRAM "+DESTAV$+" /s" RUN CommandToCopy$ CommandToCopy$ = "" END SUB '** Purpose: '** Copies Data '************************************************************************** SUB CopyData STATIC CommandToCopy$ = "xcopy "+SrcDir$+"DATA "+DESTAVDATA$+" /s" RUN CommandToCopy$ CommandToCopy$ = "" END SUB '** Purpose: '** Prepares for WINSOCK stub install '************************************************************************** SUB PrepareWINSOCKStub STATIC AddSectionFilesToCopyList "Win32appArcViewBinWINSOCKStub", SrcDir$, DESTSYS$ END SUB '** Purpose: '** Prepares for WSOCK32 stub install '************************************************************************** SUB PrepareWSOCK32Stub STATIC AddSectionFilesToCopyList "Win32appArcViewBinWSOCK32Stub", SrcDir$, DESTSYS32$ END SUB '** '** Purpose: '** Prepares for install to ArcView system files '************************************************************************** SUB PrepareSysArcView STATIC IF IsDirWritable(DESTSYS$) THEN AddSectionFilesToCopyList "WindowsSystemAvHelp", SrcDir$, DESTSYS$ END IF IF OnWin32% AND IsDirWritable(DESTSYS32$) THEN AddSectionFilesToCopyList "WindowsSystem32AvHelp", SrcDir$, DESTSYS32$ END IF END SUB '** Purpose: '** Cleans up after ArcView install '************************************************************************** SUB CleanUpArcView STATIC iconfile$ = GetIniKeyString (IniFileName$, "ArcView", "Icon") AddDebugString "Icon file is:"+iconfile$ aprfile$ = GetIniKeyString (IniFileName$, "Data", "Project") AddDebugString "Project file is:"+aprfile$ readmefile$ = GetIniKeyString (IniFileName$, "ArcView", "ReadMe") AddDebugString "Read Me file is:"+readmefile$ readmename$ = GetIniKeyString (IniFileName$, "ArcView", "ReadMeName") AddDebugString "Read Me name is:"+readmename$ programname$ = GetIniKeyString (IniFileName$, "ArcView", "Program") AddDebugString "Program name is:"+programname$ groupname$ = GetIniKeyString (IniFileName$, "ArcView", "Group") AddDebugString "Group name is:"+groupname$ CreateProgmanGroup GroupName$, "", cmoNone ShowProgmanGroup GroupName$, 1, cmoNone CreateProgmanItem GroupName$, ProductName$, DESTAV$ + "BIN\" + programname$ +" " + DESTAVDATA$ + aprfile$, DESTAV$ + "BIN\" + iconfile$ + ",,,," + DESTAVDATA$, cmoOverwrite IF readmefile <> "" THEN CreateProgmanItem GroupName$, readmename$, DESTAV$ + "ETC\" + readmefile$, "", cmoOverwrite END IF IF (ERR = 0) AND (NOT OnWin32%) THEN IF GetConfigNumFiles() < ENOUGHFILES THEN IF AVModifyFile(MODIFYCONFIGSYS, "CONFIG.SYS", "FILES=", "FILES=" + LTRIM$(RTRIM$(STR$(ENOUGHFILES)))) THEN endmsg$ = endmsg$ + "Please make sure you reboot your PC so the changes to your CONFIG.SYS can take effect." + eol$ ELSE endmsg$ = endmsg$ + "Please make sure you modify your CONFIG.SYS files to set FILES=65 and reboot your PC." + eol$ END IF END IF END IF END SUB '** Purpose: '** User interface for Data install '************************************************************************** SUB ConfirmData STATIC ProdPath$ = GetIniKeyString (IniFileName$, "Data", "Path") AddDebugString "AV OEM Data Path: " + ProdPath$ DESTAVDATA$ = MID$(DESTSYS$,1,3) + ProdPath$ DESTAVDATA$ = ConfirmPath(DESTAVDATA$, AVDATAPATH) END SUB '** Purpose: '** Confirms a path '** Arguments: '** szPath: Suggested default path '** dlg: Number of dialog box to use '** Returns: '** The path the user chose '************************************************************************** FUNCTION ConfirmPath(szPath AS STRING, dlg AS INTEGER) STATIC AS STRING SetSymbolValue "EditTextIn", szPath$ SetSymbolValue "EditFocus", "END" GETPATH: sz$ = UIStartDlg(CUIDLL$, dlg, "FEditDlgProc", 0, "") IF sz$ = "CONTINUE" THEN szPath$ = GetSymbolValue("EditTextOut") IF MID$(szPath$, LEN(szPath$), 1) <> "\" THEN szPath$ = szPath$ + "\" END IF IF IsDirWritable(szPath$) = KIT_FALSE THEN ShowMyMessage BADPATH GOTO GETPATH END IF UIPop 1 ELSEIF sz$ = "REACTIVATE" THEN GOTO GETPATH ELSEIF sz$ = "EXIT" THEN UIPop 1 ERROR STFQUIT END IF ConfirmPath = szPath$ END FUNCTION '** Purpose: '** Message about a something '************************************************************************** SUB ShowMyMessage(dlg AS INTEGER) STATIC MESSAGE: sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "") IF sz$ = "REACTIVATE" THEN GOTO MESSAGE END IF UIPop 1 END SUB '** Purpose: '** Prepares for VShare install '************************************************************************** SUB PrepareVShare STATIC AddSectionFilesToCopyList "VShare", SrcDir$, DESTSYS$ END SUB '** Purpose: '** Cleans up after VShareinstall '************************************************************************** SUB CleanUpVShare STATIC addvshare$ = DESTSYS$ + "VSHARE.386 ' Added for ArcView" END SUB '** Purpose: '** Outputs a debugging string if needed '** Arguments: '** s$ : String to output '************************************************************************** SUB AddDebugString(s$) STATIC IF isDebug% THEN WriteToLogFile s$ END IF END SUB '** Purpose: '** Outputs a debugging string for a boolean variable if needed '** Arguments: '** s$ : String to output '** b% : Boolean variable '************************************************************************** SUB AddBoolDebugString(s$,b%) STATIC IF b% THEN AddDebugString(s$+"TRUE") ELSE AddDebugString(s$+"FALSE") END IF END SUB '** Purpose: '** Compares two file version strings '** Arguments: '** first$ : First version string '** second% : Second version string '************************************************************************** FUNCTION CompareVersions(szfirst$, szsecond$) STATIC AS INTEGER result% = 0 field% = 0 NEXTFIELD: field% = field% + 1 firstn& = GetVersionNthField(szfirst$, field%) secondn& = GetVersionNthField(szsecond$, field%) IF firstn& > secondn& THEN result% = 1 ELSEIF firstn& < secondn& THEN result% = 2 END IF IF (result% = 0) AND (field% < 4) THEN GOTO NEXTFIELD END IF CompareVersions = result% END FUNCTION '** Purpose: '** Finds a command line argument '** Arguments: '** c$: Character to detect '** Returns: '** TRUE if character detected '************************************************************************** FUNCTION CommandLine(c$) STATIC AS INTEGER find% = INSTR(COMMAND$, "/"+c$) IF find% = 0 THEN find% = INSTR(COMMAND$, "/"+UCASE$(c$)) END IF IF find% <> 0 THEN COMMAND$ = MID$(COMMAND$, 1, find% - 1) + MID$(COMMAND$, find% + 2, LEN(COMMAND$) - find% - 1) END IF CommandLine = (find% <> 0) END FUNCTION