 '**************************************************************************
'**************************************************************************
DECLARE SUB InitialIzation
DECLARE SUB BadOpSysNT
DECLARE SUB BadOpSys30
DECLARE SUB WAutoFig
DECLARE SUB Notadmini
DECLARE SUB Disincentive
DECLARE SUB FindOldSoftWare
DECLARE SUB ASKEXIT
DECLARE SUB GetPath
DECLARE SUB QuitInstall
DECLARE SUB FillCopyList
DECLARE SUB FillIniFile
DECLARE FUNCTION WriteDisToFile LIB "mscuistf.dll" (Direct$) AS INTEGER
DECLARE FUNCTION ReadIniDisin   LIB "mscuistf.dll" (Direct$) AS INTEGER
DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
DECLARE FUNCTION IsWinNT LIB "mscuistf.dll" AS INTEGER
DECLARE FUNCTION FindWindow LIB "USER" (classname$, title$) AS INTEGER
DECLARE FUNCTION SwapMouseButton LIB "USER" (x%) AS INTEGER
DECLARE FUNCTION GetBasicStr LIB "string.dll" (x%) AS INTEGER
DECLARE FUNCTION SetRunLine LIB "mscuistf.dll" (lpNewLine$) AS INTEGER
DECLARE FUNCTION SetSchemes LIB "mscuistf.dll" (szThe$) AS INTEGER
DECLARE FUNCTION RegisterWindowMessage LIB "USER" (sz$) AS INTEGER

DECLARE FUNCTION NTInit LIB "MSCOMSTF" AS INTEGER
DECLARE FUNCTION NTIsDirWritable LIB "MSCOMSTF" (DirName$) AS INTEGER
DECLARE FUNCTION NTCreateDir LIB "MSCOMSTF" (DirName$) AS INTEGER
DECLARE FUNCTION NTGetWinDir LIB "MSCOMSTF" () AS INTEGER
DECLARE FUNCTION NTGetSysDir LIB "MSCOMSTF" () AS INTEGER
DECLARE FUNCTION NTCheckSecurity LIB "MSCOMSTF" AS INTEGER
DECLARE FUNCTION NTSetRegistry LIB "MSCOMSTF" (RegInfo$, lang%) AS INTEGER
DECLARE FUNCTION NTSetMouse LIB "MSCOMSTF" (MouseCode%) AS INTEGER
DECLARE FUNCTION NTReboot LIB "MSCOMSTF" (Reboot%) AS INTEGER
DECLARE FUNCTION NTFindDirs LIB "MSCOMSTF" (t1$, t2$, szDevice$) AS INTEGER

CONST WM_REBOOT    = 1536
CONST WM_WTYPE     = 1537
CONST WM_LANG      = 1538
CONST WM_NONWINKBD = 1539
CONST WM_KEYBOARD  = 1540

CONST DIS_NOT_INSTALLED = 101
CONST DIS_INSTALLED = 202
CONST DIS_CORUPTED = 303

'**************************************************************************
'**************************************************************************
SUB InitialIzation STATIC

	SetBitmap "string.dll", 1

	x% = GetBasicStr(8002)
	sz$ = GetSymbolValue("SetupString")
	SetTitle sz$
	RemoveSymbol "SetupString"

	'' Get windows type
	WINTYPE% = IsWinNT

	IF WINTYPE% = -1 THEN
		BadOpSysNT
	ELSEIF WINTYPE% = 0 THEN
		WINTYPE% = GetWindowsMajorVersion
		IF WINTYPE% = 3 THEN
			x% = GetWindowsMinorVersion
			IF x% = 0 THEN
				BadOpSys30
			ENDIF
			IF x% > 60 THEN
				WINTYPE% = 4
			ENDIF
		ENDIF
	ENDIF

	'Find out if Autoexec.bat and Config.sys are writeable
	i% = AutoFigWriteable()
	if i% = 0 then
		'Autoexec/Config.sys are read-only
		WAutoFig
	ENDIF

	'' Read setup.inf file
	szSTR$ = GetSymbolValue("STF_SRCINFPATH")
	IF szSTR$ = "" THEN
		szSTR$ = GetSymbolValue("STF_CWDDIR")
	END IF
	SETUPINF$ = szSTR$

	ReadInfFile MakePath(szSTR$, "setup.inf")

	'' Find the Mother ship
	HWIN% = FindWindow("STUFF-BOOT", NULL)
	
	'' Get source dir
	SRCDIR$ = GetSymbolValue("STF_SRCDIR")

	'' Disincentive
	RetCode% = ReadIniDisin(MakePath(SRCDIR$, "setup.ini"))

	''Make Our Default drive and path string
	IF WINTYPE% = 3 THEN
		WINDIR$ = GetWindowsDir
		WINSYSDIR$ = GetWindowsSysDir
	ELSE
		'32-Bit Windows
		x% = NTInit()
		if WINTYPE% = 1 then
			'Basic does both tests on an AND... duh!
			if NTCheckSecurity() = 0 then
				Notadmini
			endif
		endif
		'Windows and windows/System32 may use 
		'long filenames (get 8.3)
		x%= NTGetWinDir()
		WINDIR$ = GetSymbolValue("SetupString")
		RemoveSymbol "SetupString"
		x%= NTGetSysDir()
		WINSYSDIR$ = GetSymbolValue("SetupString")
		RemoveSymbol "SetupString"
	ENDIF
	
	'Default MSINPUT directory
	SHMSE$ = MID$(WINDIR$, 1, 1) + ":\MSINPUT"

	'' Set /O switch if on comand line
	SETUPTYPE$ = GetIniKeyString(MakePath(SRCDIR$, "setup.lst"), "SetupType", "OEM")

	IF SETUPTYPE$ = "TRUE" THEN
		OEMTYPE% = 1
	ELSE
		OEMTYPE% = 0
	ENDIF

	if WINTYPE% <> 4 then
		'Win16/WinNT
		'' Kill Logitech's mouse cursor stuff
		kbd& = PostMessage(FindWindow("LCURSOR",NULL), 2, 0, 0)
		'' Kill Old Pointer   This stuff is in \common\win\inc\pointer.h
		kbd& = PostMessage(FindWindow("POINTEXE","Pointer.exe Invisible Window"), 1133, 0, 0)
		'' Kill Real Old Pointer
		kd& = PostMessage(FindWindow("GROWSTUB",NULL),16,0,0)
		'' Kill Keyboard or Mouse managers
		x% = RegisterWindowMessage("PROPWINSHUTDOWN")
		kd& = PostMessage(-1,x%,0,0)
	endif

END SUB
'**************************************************************************

'**************************************************************************
'**************************************************************************
SUB BadOpSysNT STATIC

BNT:
	sz$ = UIStartDlg(COMDLL$, BADOSNT, "FQuitDlgProc", 0, "")
	IF sz$ = "HELP" THEN
		sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
		UIPop 1
		GOTO BNT
	ENDIF
	UIPopAll
	ERROR STFQUIT

END SUB
'**************************************************************************

'**************************************************************************
'**************************************************************************
SUB BadOpSys30 STATIC

B30:
	sz$ = UIStartDlg(COMDLL$, BADOS30, "FQuitDlgProc", 0, "")
	IF sz$ = "HELP" THEN
		sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
		UIPop 1
		GOTO B30
	ENDIF
	UIPopAll
	ERROR STFQUIT

END SUB
'**************************************************************************

'**************************************************************************
'**************************************************************************
SUB WAutoFig STATIC

WAF:
	sz$ = UIStartDlg(COMDLL$, WRITEAUTOFIG, "FQuitDlgProc", 0, "")
	IF sz$ = "HELP" THEN
		sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
		UIPop 1
		GOTO WAF
	ENDIF
	UIPopAll
	ERROR STFQUIT

END SUB
'**************************************************************************

'**************************************************************************
'**************************************************************************
SUB Notadmini STATIC

NA:
	sz$ = UIStartDlg(COMDLL$, NOTADMIN, "FQuitDlgProc", 0, "")
	IF sz$ = "HELP" THEN
		sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
		UIPop 1
		GOTO NA
	ENDIF
	UIPopAll
	ERROR STFQUIT

END SUB
'**************************************************************************

'**************************************************************************
'**************************************************************************
SUB Disincentive STATIC

	IF RetCode% = DIS_NOT_INSTALLED THEN

REDOO:
		sz$ = UIStartDlg(COMDLL$, CDGETNAME, "FNameOrgDlgProc", 0, "")
		szName$ = GetSymbolValue("NameOut")
		szOrg$ = GetSymbolValue("OrgOut")

		IF sz$ = "CONTINUE" THEN
			IF szName$ = "" THEN
BN:
				sz$ = UIStartDlg(COMDLL$, CDBADNAME, "FConfirmDlgProc", 0, "")
				IF sz$ = "CONTINUE" THEN
					UIPop 1
					GOTO REDOO
				ELSEIF sz$ = "CANCEL" THEN
					ASKEXIT
					GOTO BN
				ELSEIF sz$ = "HELP" THEN
					sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
					UIPop 1
					GOTO BN
				ELSE
					UIPop 2
				ENDIF
			ENDIF                   
			AddListItem "ConfirmTextIn", szName$
			AddListItem "ConfirmTextIn", szOrg$

CDCONFIRM:
			sz$ = UIStartDlg(COMDLL$, CDCONFIRMINFO, "FConfirmDlgProc", 0, "")

			RemoveSymbol "ConfirmTextIn"                                                            
			
			IF sz$ = "BACK" OR sz$ = "CANCEL" THEN
				UIPop(1)
				GOTO REDOO
			ELSEIF sz$ = "HELP" THEN
				sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
				UIPop 1
				GOTO CDCONFIRM
			ELSE
				UIPop(2)
			ENDIF

		ELSEIF sz$ = "EXIT" OR sz$ = "CANCEL" THEN
			ASKEXIT
			GOTO REDOO
		ELSEIF sz$ = "HELP" THEN
			sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
			UIPop 1
			GOTO REDOO
		ELSE
			GOTO REDOO
		ENDIF

		SetSymbolValue "INSTALLEDNAME", szName$ 
		SetSymbolValue "INSTALLEDORG", szOrg$ 
		sx% = WriteDisToFile(MakePath(SRCDIR$, "setup.ini"))
		
	ELSEIF RetCode% = DIS_INSTALLED THEN

DISINSTALLED:
		szName$ = GetSymbolValue("INSTALLEDNAME")
		szOrg$ = GetSymbolValue("INSTALLEDORG")
		szSer$ = GetSymbolValue("INSTALLEDSER")

		AddListItem "ConfirmTextIn", szName$
		AddListItem "ConfirmTextIn", szOrg$
		AddListItem "ConfirmTextIn", szSer$

		sz$ = UIStartDlg(COMDLL$, CDALREADYUSED, "FConfirmDlgProc", 0, "")
		RemoveSymbol "ConfirmTextIn"                                                            

		IF sz$ = "EXIT" OR sz$ = "CANCEL" THEN
			ASKEXIT
			GOTO DISINSTALLED
		ELSEIF sz$ = "HELP" THEN
			sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
			UIPop 1
			GOTO DISINSTALLED
		ELSE
			UIPop(1)
		ENDIF

	ELSEIF RetCode% = DIS_CORUPTED THEN

DISCORUPTED:
		sz$ = UIStartDlg(COMDLL$, CDBADFILE, "FInfoDlgProc", 0, "")

		IF sz$ = "EXIT" OR sz$ = "CANCEL" THEN
			ASKEXIT
			GOTO DISCORUPTED
		ELSEIF sz$ = "HELP" THEN
			sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
			UIPop 1
			GOTO DISCORUPTED
		ELSE
			UIPop(1)
		ENDIF

	ENDIF

END SUB
'**************************************************************************

'**************************************************************************
'**************************************************************************
SUB FindOldSoftWare STATIC

	DLG% = DESTPATH
	Cursor% = ShowWaitCursor()
		
	FOUNDOTHER% = 0
	sz$ = GetEnvVariableValue("MSINPUT")
	IF sz$="" AND WINTYPE% <> 3 THEN
		'Win95 and WinNT
		i% = NTFindDirs("", "", "MOUSE")
		IF i% <> 0 THEN
			sz$ = GetSymbolValue("SetupString")
		ENDIF
	ENDIF
		
	IF sz$ <> "" THEN
		FOUNDOTHER% = 1
		SHMSE$ = sz$
		IF FindFileUsingFileOpen(MakePath(sz$,"MOUSE\UNINSTAL.EXE")) <> "" THEN
			DLG% = FOUNDSOFT
		ENDIF
		'Check if previous Keyboard product was installed
		IF FindFileUsingFileOpen(MakePath(SHMSE$,"KEYBOARD\KBDX16.EXE")) <> "" THEN
			IF FindFileUsingFileOpen(MakePath(SHMSE$,"KEYBOARD\NTFILE.EXE")) = "" THEN
				'Nexus
				szIni$ = MakePath(SHMSE$,"MSINPUT.INI")
				CreateIniKeyValue szIni$, "Setup", "OldKeyboard.Win16", MakePath(SHMSE$, "KEYBOARD"), cmoOverwrite
			ENDIF
		ENDIF
	ENDIF

	RestoreCursor Cursor

END SUB
'**************************************************************************

'**************************************************************************
'**************************************************************************
SUB GetPath STATIC

FOUND:
	IF FOUNDOTHER% = 1 THEN
		AddListItem "ConfirmTextIn", SHMSE$
		'' Do you realy want to change the directory?
DET:
		sz$ = UIStartDlg(COMDLL$, DETECT, "FConfirmDlgProc", 0, "")
		IF sz$ = "CONTINUE" THEN
			UIPop 1
			GOTO XSTALL
		ELSEIF sz$ = "CANCEL" THEN
			ASKEXIT
			GOTO DET
		ELSEIF sz$ = "HELP" THEN
			sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
			UIPop 1
			GOTO DET
		ENDIF
		UIPop 1

		AddListItem "ConfirmTextIn", SHMSE$
		'' Do you REALY REALLY want to change the directory?
WARN:
		sz$ = UIStartDlg(COMDLL$, WARNING, "FConfirmDlgProc", 0, "")
		IF sz$ = "CONTINUE" THEN
			UIPop 1
			GOTO XSTALL
		ELSEIF sz$ = "CANCEL" THEN
			ASKEXIT
			GOTO WARN
		ELSEIF sz$ = "HELP" THEN
			sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
			UIPop 1
			GOTO WARN
		ENDIF
		UIPop 1
	ENDIF

	SetSymbolValue "EditTextIn", SHMSE$
	SetSymbolValue "EditFocus", "ALL"
GETPATHL1:
	sz$ = UIStartDlg(COMDLL$, DLG%, "FEditDlgProc", 0, "")
	IF sz$ = "CONTINUE" THEN
		SHMSE$ = GetSymbolValue("EditTextOut")
		if SHMSE$ = "" then
			goto BADPATH
		endif
RMBACK:
		IF MID$(SHMSE$, LEN(SHMSE$), 1) = "\" THEN
			IF LEN(SHMSE$) > 3 THEN
				SHMSE$ = MID$(SHMSE$, 1, LEN(SHMSE$)-1)
				GOTO RMBACK
			ENDIF
		ENDIF

		IF IsDirWritable(SHMSE$) = 0 THEN
BADPATH:
			sz$ = UIStartDlg(COMDLL$, BADPATH, "FInfo0DlgProc", 0, "")
			IF sz$ = "REACTIVATE" THEN
				GOTO BADPATH
			ELSEIF sz$ = "HELP" THEN
				sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
				UIPop 1
				GOTO BADPATH
			END IF
			UIPop 1

			GOTO GETPATHL1

		END IF
		UIPop 1

		'' Is there room on the drive?
		IF WINTYPE% = 1 OR WINTYPE% = 4 THEN
			   ''   INPUT   USER
			need& = 347957 + 422923
		ELSEIF WINTYPE% = 3 THEN
			   ''   INPUT   USER
			need& = 271697 + 345995
		ENDIF
		drive$ = MID$(SHMSE$, 1, 1)

		IF need& > GetFreeSpaceForDrive(drive$) THEN
NOSPACE:
			sz$ = UIStartDlg(COMDLL$, NOSPACEEXPRESS, "FInfo0DlgProc", 0, "")
			IF sz$ = "CONTINUE" THEN
				UIPop 1
				GOTO GETPATHL1
			ELSEIF sz$ = "BACK" OR sz$ = "CANCEL" THEN
				UIPop 1
				ASKEXIT
				GOTO GETPATHL1
			ELSEIF sz$ = "REACTIVATE" THEN
				GOTO NOSPACE
			ELSEIF sz$ = "HELP" THEN
				sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
				UIPop 1
				GOTO NOSPACE
			ELSE
				GOTO GETPATHL1
			END IF
		END IF
	ELSEIF sz$ = "EXIT" OR sz$ = "CANCEL" THEN
		ASKEXIT
		GOTO GETPATHL1
	ELSEIF sz$ = "HELP" THEN
		sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
		UIPop 1
		GOTO GETPATHL1
	ELSE
		GOTO GETPATHL1
	END IF

XSTALL:

END SUB
'**************************************************************************

'*************************************************************************
'*************************************************************************
SUB QuitInstall STATIC

	IF ERR = 0 THEN
ES:
		sz$ = UIStartDlg(COMDLL$, EXITSUCCESS, "FInfoDlgProc", 0, "")
		IF sz$ = "EXIT" OR sz$ = "CANCEL" THEN
			UIPop 1
			x% = PostMessage(HWIN%, 1536, 0, 0)
		ELSEIF sz$ = "BACK" THEN
			UIPop 1
			x% = PostMessage(HWIN%, 1536, 1, 0)
		ELSEIF sz$ = "HELP" THEN
			sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
			UIPop 1
			GOTO ES
		ELSE
			GOTO ES
		END IF
		x% = PostMessage(FindWindow("MS_WINHELP",NULL), 2, 0, 0)
		END

	ELSEIF ERR = STFQUIT THEN
		dlg% = EXITQUIT
	ELSE
		dlg% = EXITFAILURE
	END IF
QUITL1:
	sz$ = UIStartDlg(COMDLL$, dlg%, "FInfo0DlgProc", 0, "")
	IF sz$ = "REACTIVATE" THEN
		GOTO QUITL1
	ELSEIF sz$ = "HELP" THEN
		sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
		UIPop 1
		GOTO QUITL1
	ENDIF
	UIPop 1
	x% = PostMessage(HWIN%, 1536, 0, 0)
	
	END
 
	
END SUB
'*************************************************************************

'*************************************************************************
'*************************************************************************
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
'*************************************************************************

'*************************************************************************
'*************************************************************************
SUB ASKEXIT STATIC
ASKQUIT:
	sz$ = UIStartDlg(COMDLL$, ASKQUIT, "FQuitDlgProc", 0, "")
	IF sz$ = "EXIT" OR sz$ = "CANCEL" THEN
		UIPopAll
		ERROR STFQUIT
	ELSEIF sz$ = "REACTIVATE" THEN
		GOTO ASKQUIT
	ELSEIF sz$ = "HELP" THEN
		sz$ = UIStartDlg(COMDLL$, NOHELP, "FHelpDlgProc", 0, "")
		UIPop 1
		GOTO ASKQUIT
	ELSE
		UIPop 1
	END IF

END SUB
'*************************************************************************

'*************************************************************************
'*************************************************************************
SUB FillCopyList STATIC

	ClearCopyList

	'[Setup] section keeps track of installations
	szIni$ = MakePath(SHMSE$,"MSINPUT.INI")

	'Check if previous Mouse or Keyboard product was installed
	IF FindFileUsingFileOpen(MakePath(WINSYSDIR$,"IDINTL.DLL")) <> "" THEN
		'Antigua or Nexus found
		CreateIniKeyValue szIni$, "Setup", "Other.Win16", SHMSE$, cmoOverwrite
	ENDIF

	LangType = SendMessage(HWIN%, WM_LANG, 0, 0)
	
	IF LangType = 70 THEN           ' we have japanse
		NewWinType% = IsWinNT
		IF NewWinType% = 1 THEN         ' we have WinNT
			MOTYPE$="MoNT"
		ENDIF
	ENDIF
	
	IF CUSTOM1$ = "ON" THEN
		if WINTYPE% = 4 then
			'Win95 CPMNGR32 goes to WinDir
			AddSectionKeyFileToCopyList MOTYPE$, "ZA", SRCDIR$, WINDIR$
		else
			'Win16/WinNT/Daytona CPMNGR16/32 goes to WinSysDir
			AddSectionKeyFileToCopyList MOTYPE$, "ZA", SRCDIR$, WINSYSDIR$
		endif

		AddSectionKeyFileToCopyList MOTYPE$, "ZB", SRCDIR$, SHDST$
		AddSectionKeyFileToCopyList MOTYPE$, "ZC", SRCDIR$, SHDST$
		AddSectionKeyFileToCopyList MOTYPE$, "ZD", SRCDIR$, SHMSE$

		IF POINTER1$ = "ON" THEN
			AddSectionKeyFileToCopyList MOTYPE$, "A", SRCDIR$, SHDST$
			AddSectionKeyFileToCopyList "Cursor", "B", SRCDIR$, SHEFF$
			if WINTYPE% = 3 then
				'Win16
				AddSectionFilesToCopyList "MFX", SRCDIR$, SHEFF$
			else
				'Win95/WinNT/Daytona
				AddSectionFilesToCopyList "ANI", SRCDIR$, SHEFF$
			endif
		ENDIF

		IF POINTER2$ = "ON" THEN
			AddSectionKeyFileToCopyList MOTYPE$, "B", SRCDIR$, SHDST$
		ENDIF

		IF POINTER3$ = "ON" THEN
			AddSectionKeyFileToCopyList MOTYPE$, "C", SRCDIR$, SHDST$
		ENDIF

		IF POINTER4$ = "ON" THEN
			AddSectionKeyFileToCopyList MOTYPE$, "D", SRCDIR$, SHDST$
		ENDIF

		IF POINTER5$ = "ON" THEN
			AddSectionKeyFileToCopyList MOTYPE$, "E", SRCDIR$, SHDST$
		ENDIF

		IF POINTER6$ = "ON" THEN
			if WINTYPE% = 3 THEN
				'Win16
				AddSectionKeyFileToCopyList MOTYPE$, "F", SRCDIR$, SHDST$
			else
				AddSectionFilesToCopyList "SCHEMES", SRCDIR$, SHEFF$
			endif
			AddSectionKeyFileToCopyList "Cursor", "A", SRCDIR$, SHEFF$
		ENDIF

		IF POINTER7$ = "ON" THEN
			AddSectionKeyFileToCopyList MOTYPE$, "G", SRCDIR$, SHDST$
		ENDIF

		IF POINTER8$ = "ON" THEN
			AddSectionKeyFileToCopyList MOTYPE$, "H", SRCDIR$, SHDST$
		ENDIF
	ENDIF

	IF CUSTOM2$ = "ON" THEN
		AddSectionKeyFileToCopyList MOTYPE$, "T", SRCDIR$, SHDST$
		IF (LANGTYPE = 70) AND (IsWinNT = 1) THEN
			AddSectionKeyFileToCopyList "Common", "INBRNT", SRCDIR$, WINDIR$                
		ELSE
			AddSectionKeyFileToCopyList "Common", "INBAR", SRCDIR$, WINDIR$
		ENDIF                           
		AddSectionKeyFileToCopyList MOTYPE$, "U", SRCDIR$, SHDST$
	ENDIF

	' 70 = Japanese and we do not want to copy any DOS files over
	' 71 = Korean 
	IF (LANGTYPE = 70) OR (LANGTYPE= 71) THEN
		CUSTOM3$ = "OFF"
		CUSTOM4$ = "OFF"
		LangType = 65
	ENDIF
	

	IF CUSTOM3$ = "ON" THEN
		AddSectionKeyFileToCopyList "MiscDos", "B", SRCDIR$, SHDST$
		IF LangType = 66 THEN
			AddSectionKeyFileToCopyList "DosLan", "B", SRCDIR$, SHDST$
		ELSEIF LangType = 67 THEN
			AddSectionKeyFileToCopyList "DosLan", "C", SRCDIR$, SHDST$
		ELSEIF LangType = 68 THEN
			AddSectionKeyFileToCopyList "DosLan", "D", SRCDIR$, SHDST$
		ELSEIF LangType = 69 THEN
			AddSectionKeyFileToCopyList "DosLan", "E", SRCDIR$, SHDST$
		ELSE
			'Default to English
			AddSectionKeyFileToCopyList "DosLan", "A", SRCDIR$, SHDST$
		ENDIF
	ENDIF

	IF CUSTOM4$ = "ON" THEN
		AddSectionKeyFileToCopyList "MiscDos", "A", SRCDIR$, SHDST$
		IF LangType = 66 THEN
			AddSectionKeyFileToCopyList "MiscDos", "ZB", SRCDIR$, SHDST$
		ELSEIF LangType = 67 THEN
			AddSectionKeyFileToCopyList "MiscDos", "ZC", SRCDIR$, SHDST$
		ELSEIF LangType = 68 THEN
			AddSectionKeyFileToCopyList "MiscDos", "ZD", SRCDIR$, SHDST$
		ELSEIF LangType = 69 THEN
			AddSectionKeyFileToCopyList "MiscDos", "ZE", SRCDIR$, SHDST$
		ELSE
			'Default to English
			AddSectionKeyFileToCopyList "MiscDos", "ZA", SRCDIR$, SHDST$
		ENDIF
	ENDIF

	IF CUSTOM5$ = "ON" THEN
		IF LangType = 66 THEN
			AddSectionKeyFileToCopyList "Common", "B", SRCDIR$, SHDST$ 
			IF WINTYPE% = 4 THEN
				AddSectionKeyFileToCopyList "Common", "CB", SRCDIR$, MAKEPATH(WINDIR$, "HELP")
				AddSectionKeyFileToCopyList "Common", "CBCNT", SRCDIR$, MAKEPATH(WINDIR$, "HELP")
			ENDIF
		ELSEIF LangType = 67 THEN
			AddSectionKeyFileToCopyList "Common", "C", SRCDIR$, SHDST$ 
			IF WINTYPE% = 4 THEN
				AddSectionKeyFileToCopyList "Common", "CC", SRCDIR$, MAKEPATH(WINDIR$, "HELP")
				AddSectionKeyFileToCopyList "Common", "CCCNT", SRCDIR$, MAKEPATH(WINDIR$, "HELP")
			ENDIF
		ELSEIF LangType = 68 THEN
			AddSectionKeyFileToCopyList "Common", "D", SRCDIR$, SHDST$ 
			IF WINTYPE% = 4 THEN
				AddSectionKeyFileToCopyList "Common", "CD", SRCDIR$, MAKEPATH(WINDIR$, "HELP")
				AddSectionKeyFileToCopyList "Common", "CDCNT", SRCDIR$, MAKEPATH(WINDIR$, "HELP")
			ENDIF
		ELSEIF LangType = 69 THEN
			AddSectionKeyFileToCopyList "Common", "E", SRCDIR$, SHDST$ 
			IF WINTYPE% = 4 THEN
				AddSectionKeyFileToCopyList "Common", "CE", SRCDIR$, MAKEPATH(WINDIR$, "HELP")
				AddSectionKeyFileToCopyList "Common", "CECNT", SRCDIR$, MAKEPATH(WINDIR$, "HELP")
			ENDIF
		ELSE
			'Default to English
			AddSectionKeyFileToCopyList "Common", "A", SRCDIR$, SHDST$ 
			IF WINTYPE% = 4 THEN
				AddSectionKeyFileToCopyList "Common", "CA", SRCDIR$, MAKEPATH(WINDIR$, "HELP")
				AddSectionKeyFileToCopyList "Common", "CACNT", SRCDIR$, MAKEPATH(WINDIR$, "HELP")
			ENDIF
		ENDIF
	ENDIF

	IF WINTYPE% = 3 THEN
		'Win16
		IF LangType = 66 THEN
			CreateIniKeyValue szIni$, "Setup", "Mouse.Lng", "German", cmoOverwrite
			AddSectionKeyFileToCopyList "WinLan", "CB", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "WinLan", "MB", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "Common", "L", SRCDIR$, SHDST$
			AddSectionKeyFileToCopyList "Write", "L", SRCDIR$, SHDST$
		ELSEIF LangType = 67 THEN
			CreateIniKeyValue szIni$, "Setup", "Mouse.Lng", "French", cmoOverwrite
			AddSectionKeyFileToCopyList "WinLan", "CC", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "WinLan", "MC", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "Common", "M", SRCDIR$, SHDST$
			AddSectionKeyFileToCopyList "Write", "M", SRCDIR$, SHDST$
		ELSEIF LangType = 68 THEN
			CreateIniKeyValue szIni$, "Setup", "Mouse.Lng", "Spanish", cmoOverwrite
			AddSectionKeyFileToCopyList "WinLan", "CD", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "WinLan", "MD", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "Common", "N", SRCDIR$, SHDST$
			AddSectionKeyFileToCopyList "Write", "N", SRCDIR$, SHDST$
		ELSEIF LangType = 69 THEN
			CreateIniKeyValue szIni$, "Setup", "Mouse.Lng", "Italian", cmoOverwrite
			AddSectionKeyFileToCopyList "WinLan", "CE", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "WinLan", "ME", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "Common", "O", SRCDIR$, SHDST$
			AddSectionKeyFileToCopyList "Write", "O", SRCDIR$, SHDST$
		ELSE
			'Default to English
			CreateIniKeyValue szIni$, "Setup", "Mouse.Lng", "English", cmoOverwrite
			AddSectionKeyFileToCopyList "WinLan", "CA", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "WinLan", "MA", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "Common", "K", SRCDIR$, SHDST$
		ENDIF
	ELSE
		'WinNT/Win95/Daytona
		IF LangType = 66 THEN
			CreateIniKeyValue szIni$, "Setup", "Mouse.Lng", "German", cmoOverwrite
			AddSectionKeyFileToCopyList "WinLan", "ML", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "Common", "L", SRCDIR$, SHDST$
			AddSectionKeyFileToCopyList "Write", "L", SRCDIR$, SHDST$
			if WINTYPE% = 4 then
				'Win95 COMLNG32 goes to WinDir
				AddSectionKeyFileToCopyList "WinLan", "CL", SRCDIR$, WINDIR$
			else
				'WinNT/Daytona COMLNG32 goes to WinSysDir
				AddSectionKeyFileToCopyList "WinLan", "CL", SRCDIR$, WINSYSDIR$
			endif
		ELSEIF LangType = 67 THEN
			CreateIniKeyValue szIni$, "Setup", "Mouse.Lng", "French", cmoOverwrite
			AddSectionKeyFileToCopyList "WinLan", "MM", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "Common", "M", SRCDIR$, SHDST$
			AddSectionKeyFileToCopyList "Write", "M", SRCDIR$, SHDST$
			if WINTYPE% = 4 then
				'Win95 COMLNG32 goes to WinDir
				AddSectionKeyFileToCopyList "WinLan", "CM", SRCDIR$, WINDIR$
			else
				'WinNT/Daytona COMLNG32 goes to WinSysDir
				AddSectionKeyFileToCopyList "WinLan", "CM", SRCDIR$, WINSYSDIR$
			endif
		ELSEIF LangType = 68 THEN
			CreateIniKeyValue szIni$, "Setup", "Mouse.Lng", "Spanish", cmoOverwrite
			AddSectionKeyFileToCopyList "WinLan", "MN", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "Common", "N", SRCDIR$, SHDST$
			AddSectionKeyFileToCopyList "Write", "N", SRCDIR$, SHDST$
			if WINTYPE% = 4 then
				'Win95 COMLNG32 goes to WinDir
				AddSectionKeyFileToCopyList "WinLan", "CN", SRCDIR$, WINDIR$
			else
				'WinNT/Daytona COMLNG32 goes to WinSysDir
				AddSectionKeyFileToCopyList "WinLan", "CN", SRCDIR$, WINSYSDIR$
			endif
		ELSEIF LangType = 69 THEN
			CreateIniKeyValue szIni$, "Setup", "Mouse.Lng", "Italian", cmoOverwrite
			AddSectionKeyFileToCopyList "WinLan", "MO", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "Common", "O", SRCDIR$, SHDST$
			AddSectionKeyFileToCopyList "Write", "O", SRCDIR$, SHDST$
			if WINTYPE% = 4 then
				'Win95 COMLNG32 goes to WinDir
				AddSectionKeyFileToCopyList "WinLan", "CO", SRCDIR$, WINDIR$
			else
				'WinNT/Daytona COMLNG32 goes to WinSysDir
				AddSectionKeyFileToCopyList "WinLan", "CO", SRCDIR$, WINSYSDIR$
			endif
		ELSE
			'Default to English
			CreateIniKeyValue szIni$, "Setup", "Mouse.Lng", "English", cmoOverwrite
			AddSectionKeyFileToCopyList "WinLan", "MK", SRCDIR$, WINSYSDIR$
			AddSectionKeyFileToCopyList "Common", "K", SRCDIR$, SHDST$
			if WINTYPE% = 4 then
				'Win95 COMLNG32 goes to WinDir
				AddSectionKeyFileToCopyList "WinLan", "CK", SRCDIR$, WINDIR$
			else
				'WinNT/Daytona COMLNG32 goes to WinSysDir
				AddSectionKeyFileToCopyList "WinLan", "CK", SRCDIR$, WINSYSDIR$
			endif
		ENDIF
	ENDIF


	IF WINTYPE% = 3 THEN
		'Win16
		CreateIniKeyValue szIni$, "Setup", "Mouse.Win16", SHDST$, cmoOverwrite
		AddSectionFilesToCopyList "Sys16", SRCDIR$, WINSYSDIR$
		AddSectionFilesToCopyList "Win16drv", SRCDIR$, SHMSE$
		AddSectionKeyFileToCopyList "Win16", "A", SRCDIR$, SHMSE$
		AddSectionKeyFileToCopyList "Win16", "B", SRCDIR$, SHMSE$
		AddSectionKeyFileToCopyList "Win16", "CM", SRCDIR$, WINSYSDIR$

	ELSE
		'WinNT/Win95/Daytona
		IF WINTYPE% = 1 THEN
			'WinNT/Daytona only
			CreateIniKeyValue szIni$, "Setup", "Mouse.WinNT", SHDST$, cmoOverwrite
			AddSectionFilesToCopyList "Sys32", SRCDIR$, WINSYSDIR$
			AddSectionFilesToCopyList "WinNTdrv", SRCDIR$, MAKEPATH(WINSYSDIR$, "DRIVERS")
			'POINT32.* (goes to %MSINPUT% on WinNT)
			AddSectionKeyFileToCopyList "Win32", "A", SRCDIR$, SHMSE$
			AddSectionKeyFileToCopyList "Win32", "B", SRCDIR$, SHMSE$
			'CMTOOL32.DLL goes to WinSysDir on WinNT
			AddSectionKeyFileToCopyList "Win32", "CM", SRCDIR$, WINSYSDIR$
		ELSE
			'Win95
			AddSectionKeyFileToCopyList "Win32", "VMOUSE", SRCDIR$, WINSYSDIR$
			CreateIniKeyValue szIni$, "Setup", "Mouse.Win95", SHDST$, cmoOverwrite
			'POINT32.* (goes to product dir and then gets
			'moved to %MSINPUT% by wininit.ini)
			AddSectionKeyFileToCopyList "Win32", "A", SRCDIR$, SHDST$
			AddSectionKeyFileToCopyList "Win32", "B", SRCDIR$, SHDST$
			'CMTOOL32.DLL goes to WinSysDir on Win95
			AddSectionKeyFileToCopyList "Win32", "CM", SRCDIR$, WINDIR$
		ENDIF
	ENDIF
	
	AddSectionKeyFileToCopyList "Common", "X", SRCDIR$, SHDST$
	AddSectionKeyFileToCopyList "Common", "MCP", SRCDIR$, SHDST$
	AddSectionKeyFileToCopyList "Common", "MOUSEX", SRCDIR$, WINDIR$
	AddSectionKeyFileToCopyList "Files", "UNINSTAL", SRCDIR$, SHDST$
	AddSectionKeyFileToCopyList "Files", "NTFILE", SRCDIR$, SHDST$

END SUB
'*************************************************************************

'*************************************************************************
'*************************************************************************
SUB FillIniFile STATIC

	ini$ = MakePath(WINDIR$, "SYSTEM.INI")
	CreateIniKeyValue ini$, "386Enh", "keyboard", MakePath(SHMSE$,"msinput.386"), cmoOverwrite
	CreateIniKeyValue ini$, "386Enh", "mouse", "*vmd", cmoOverwrite
	CreateIniKeyValue ini$, "boot", "mouse.drv", MakePath(SHMSE$,"MSINPUT.DRV"), cmoOverwrite
	CreateIniKeyValue ini$, "boot.description", "mouse.drv", "Microsoft IntelliPoint version 10.1", cmoOverwrite

	ini$ = MakePath(SHMSE$,"MSINPUT.INI")
	CreateIniKeyValue ini$, "Directories", "Mouse", SHDST$, cmoOverwrite
	CreateIniKeyValue ini$, "Mouse", "ClickLock", "0", cmoNone
	CreateIniKeyValue ini$, "Mouse", "RotationAngle", "0", cmoNone
	IF SwapMouseButton(0) = 1 THEN
		x% = SwapMouseButton(1)
		x% = WriteProfileString("windows", "SwapMouseButtons", "no")
		CreateIniKeyValue ini$, "Mouse", "PrimaryButton", "3", cmoNone
		CreateIniKeyValue ini$, "Mouse", "SecondaryButton", "1", cmoNone
	ELSE
		CreateIniKeyValue ini$, "Mouse", "PrimaryButton", "1", cmoNone
		CreateIniKeyValue ini$, "Mouse", "SecondaryButton", "3", cmoNone
	ENDIF
	CreateIniKeyValue ini$, "Mouse", "HorizontalSensitivity", "50", cmoNone
	CreateIniKeyValue ini$, "Mouse", "VerticalSensitivity", "50", cmoNone
	CreateIniKeyValue ini$, "Mouse", "ActiveAccelerationProfile", "2", cmoNone
	CreateIniKeyValue ini$, "Mouse", "SplashScreen", "ON", cmoNone
	CreateIniKeyValue ini$, "Mouse", "MouseType", "PS2", cmoNone
	CreateIniKeyValue ini$, "Mouse", "Device", "Mouse", cmoNone
	CreateIniKeyValue ini$, "Mouse", "PhysicalButtons", "2", cmoNone
	CreateIniKeyValue ini$, "Mouse", "MouseIcon", "2", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "SnapTo", "OFF", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "SnapBack", "OFF", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "ScreenWrap", "OFF", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "PointerSize", "", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "PointerColor", "", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "Growth", "", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "Threshold", "", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "Delay", "", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "Sonar", "OFF", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "Locate", "OFF", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "SlowMotion", "OFF", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "ClickSaver", "OFF", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "PointerHide", "OFF", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "LineLock", "OFF", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "AppScroller", "OFF", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "Chord", "OFF", cmoNone
	CreateIniKeyValue ini$, "WindowsPointer", "Secondary", "OFF", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "AlwaysOnTop", "ON", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "ReturnFocus", "ON", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "HideTitleBar", "OFF", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "MinimizeOnUse", "OFF", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "ToolTips", "ON", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "ToolbarPositionX", "140", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "ToolbarPositionY", "125", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "ToolbarRows", "1", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "ToolbarColumns", "6", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "MagnifyBtn", "ON", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "AppScrollBtn", "ON", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "LineLockBtn", "ON", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "AlternateButtonBtn", "OFF", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "Trails", "OFF", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "ClickLockBtn", "OFF", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "ControlPanelBtn", "ON", cmoNone
	CreateIniKeyValue ini$, "ToolBar", "HelpBtn", "ON", cmoNone

	x% = SetSchemes (ini$)

	ini$ = ""

END SUB
'*************************************************************************

'*************************************************************************
'*************************************************************************

'**
'** Purpose:
'**      Sets drive status info according to latest disk space calcs.
'** Arguments:
'**      none.
'** Returns:
'**      none.
'*************************************************************************
SUB SetDriveStatus STATIC

	drive$ = MID$(SHMSE$, 1, 1)

	ReplaceListItem DRIVETEXT$, 1, SHMSE$
	free& = COSTLIST& + POINTCOST& + TOOLCOST& + DOSDRV& + DOSPOINT& + ONHELP&
	ReplaceListItem DRIVETEXT$, 2, STR$(free& / 1024) + " K"
	free& = GetFreeSpaceForDrive(drive$)
	ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K"

END SUB

