home *** CD-ROM | disk | FTP | other *** search
- '**************************************************************************
- '*
- '* HP Copier v1.0 Setup
- '*
- '* Version for HP DeskScan II v2.1 Distribution Disks
- '*
- '* History:
- '* -------
- '* 940612 klb Inherited from Microsoft Windows v3.1 SDK (SAMPLE1.MST)
- '* 940721 klb Initial modifications and Turn-on complete for HP Copier.
- '*
- '* (c) Copyright Hewlett-Packard Company, 1994.
- '* All rights are reserved. Copying or other reproduction of
- '* this program except for archival purposes is prohibited
- '* without the prior written consent of Hewlett-Packard Company.
- '*
- '* RESTRICTED RIGHTS LEGEND
- '*
- '* Use, duplication, or disclosure by the Government is subject to
- '* restrictions as set forth in paragraph (b) (3) (B) of the Rights
- '* in Technical Data and Computer Software clause in DAR 7-104.9(a).
- '*
- '* HEWLETT-PACKARD COMPANY
- '* Greeley, Colorado
- '*****************************************************************************/
- '*
- '**************************************************************************
-
- ''$DEFINE DEBUG ''Define for script development/debugging
-
- '$INCLUDE 'setupapi.inc'
- '$INCLUDE 'msdetect.inc'
- '$INCLUDE 'cpcui.inc'
-
- '' *******************************
- '' ********** CONSTANTS **********
- '' *******************************
-
- '' ********** Bitmap ID **********
-
- CONST LOGO = 10
-
- '' ********* Dialog ID's *********
-
- CONST DLG_WELCOME = 100
- CONST DLG_HELPWELCOME = 200
- CONST DLG_DESTPATH = 300
- CONST DLG_HELPDESTPATH = 400
- CONST DLG_CONFIRMINFO = 500
- CONST DLG_GROUPNAME = 600
- CONST DLG_HELPGROUPNAME = 700
- CONST DLG_EXITINCOMPLETE = 2000
- CONST DLG_EXITSUCCESS = 2100
- CONST DLG_ERRBADPATH = 4000
- CONST DLG_ERRSETUPFAILED = 4100
- CONST DLG_ERRTOOBIG = 4200
-
- '' ********* String ID's *********
-
- CONST STR_ABOUT1 = 10
- CONST STR_ABOUT2 = 20
- CONST STR_GROUPSTRING = 30
- CONST STR_NOTEPAD = 40
- CONST STR_PROGMANGROUP = 50
- CONST STR_README = 60
- CONST STR_SETUP = 70
- CONST STR_TITLE = 80
- CONST STR_UIDLL = 90
- CONST STR_INFNAME = 100
- CONST STR_DEFPATH = 110
- CONST STR_ININAME = 120
- CONST STR_HPCOPIER = 130
- CONST STR_INSTALLPATH = 140
- CONST STR_NAME = 150
- CONST ERR_CORRUPTSOURCES = 1000
- CONST ERR_DOSVERSION = 1010
- CONST ERR_WINDOWSMODE = 1020
- CONST ERR_WINDOWSVERSION = 1030
-
- '' ********** GLOBALS ************
-
- GLOBAL gHELPPROC$ ''Proc handle for Help routine
- GLOBAL gWINDIR$ ''Path to WINDOWS directory
-
- '' ******** SUBROUTINES **********
-
- DECLARE SUB Install ''Where the installation action is
- DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING
-
-
- ''***************************************************************************
- ''*********** BEGINNING OF SCRIPT **********
- ''***************************************************************************
-
- INIT:
- dim sz$ ''Generic string return code
- dim errStr$ ''Generic error string
- dim szAbout1$ ''First line of the About box
- dim szAbout2$ ''Second line of the About box
- dim szCuiName$ ''File name of our custom UI DLL
- dim szDestDir$ ''Destination directory for the files
- dim szDefGroup$ ''Default ProgMan group name
- dim szDestDisk$ ''Disk Drive to install onto
- dim szNotepad$ ''File name of the NOTEPAD utility
- dim szReadme$ ''File name of the readme file
- dim szSelGroup$ ''Selected group name
- dim szTitle$ ''Title of the main window
-
- dim dlg% ''Generic dialog identifier
- dim DlgMode% ''Mode used for DoMsgBox() calls
- dim hWnd% ''Window handle of the main window
- dim i% ''Generic integer return code
- dim ListMade% ''0=Haven't made ProgMan combo box list
- ''1=ProgMan combo box list initialized
- dim MajVer% ''Major version number (Windows or DOS)
- dim MinVer% ''Minor version number (Windows or DOS)
- dim WinMode% ''Windows operating mode
- dim ShowReadme% ''0=Don't show README.TXT file
- ''1=Show README.TXT file after install
- dim FreeSpace& ''Free space on dest disk (in bytes)
-
-
- ''Some general initialization...
- hWnd% = HwndFrame() ''Handle to our main window
- DlgMode% = MB_TASKMODAL+MB_ICONHAND+MB_OK
- ListMade% = 0 ''ProgMan group list not initialized
- ShowReadme% = 1 ''Assume that README.TXT will be shown
-
- gHELPPROC$ = "FHelpDlgProc" ''Help procedure
- gWINDIR$ = GetWindowsDir() ''WINDOWS directory path (+ ending '\')
-
- szAbout1$ = STRING$(256,0)
- szAbout2$ = STRING$(64,0)
- szCuiName$ = STRING$(16,0)
- szDefGroup$ = STRING$(64,0)
- szDestDir$ = STRING$(144,0)
- szDestDisk$ = STRING$(16,0)
- szNotepad$ = STRING$(16,0)
- szReadme$ = STRING$(16,0)
- szSelGroup$ = STRING$(64,0)
- szTitle$ = STRING$(32,0)
-
- i% = FAcquireString(STR_ABOUT1, szAbout1$, 256)
- i% = FAcquireString(STR_ABOUT2, szAbout2$, 64)
- i% = FAcquireString(STR_UIDLL, szCuiName$, 16)
- i% = FAcquireString(STR_GROUPSTRING, szDefGroup$, 64)
- i% = FAcquireString(STR_DEFPATH, szDestDir$, 144)
- i% = FAcquireString(STR_NOTEPAD, szNotepad$, 16)
- i% = FAcquireString(STR_README, szReadme$, 16)
- i% = FAcquireString(STR_TITLE, szTitle$, 32)
-
- szDestDisk$ = MID$(szDestDir$, 1, 1)
- FreeSpace& = GetFreeSpaceForDrive(szDestDisk$)
-
- IF (FreeSpace& < 0) THEN
- FreeSpace& = 0
- END IF
-
-
- ''Create place holders for setup information that will be displayed
- ''in a "ConfirmInfo" dialog. One "AddListItem" is needed for each
- ''piece of data that will be displayed. The NULLs will be replaced
- ''based on information entered by the user.
-
- AddListItem "ConfirmTextIn", "" ''Destination Drive
- AddListItem "ConfirmTextIn", "" ''ProgMan Group Name
-
- ''Initialize the Default Install Directory and Destination Directory
- ''symbols. They're initially the same directory...
- SetSymbolValue "symDefaultDirectory", szDestDir$
- SetSymbolValue "symDestDirectory", szDestDir$
-
- ''Remember how much disk space is available on the default drive...
- SetSymbolValue "symSpaceAvail", STR$(FreeSpace& / 1024) + " K"
-
- ''Initialize the Program Manager Group Name string stuff...
- SetSymbolValue "symSelectedGroup", szDefGroup$
-
-
- ''Verify DOS version: Must be DOS 5.0 or better...
- MajVer% = GetDOSMajorVersion()
- MinVer% = GetDOSMinorVersion()
- IF (MajVer% < 5) THEN
- i% = FAcquireString(ERR_DOSVERSION, errStr$, 128)
- i% = DoMsgBox(errStr$, szTitle$, DlgMode%)
- dlg% = EXITFAILURE
- GOTO QUIT1
- END IF
-
-
- ''Verify Windows version and mode: Must be Windows 3.1 or better...
- MajVer% = GetWindowsMajorVersion()
- MinVer% = GetWindowsMinorVersion()
- IF (MajVer% < 3) OR ((MajVer% = 3) AND (MinVer% < 1)) THEN
- i% = FAcquireString(ERR_WINDOWSVERSION, errStr$, 128)
- i% = DoMsgBox(errStr$, szTitle$, DlgMode%)
- dlg% = EXITFAILURE
- GOTO QUIT1
- END IF
-
- WinMode% = GetWindowsMode()
- IF WinMode% = 0 THEN
- i% = FAcquireString(ERR_WINDOWSMODE, errStr$, 128)
- i% = DoMsgBox(errStr$, szTitle$, DlgMode%)
- dlg% = EXITFAILURE
- GOTO QUIT1
- END IF
-
-
- ''Set up the About box to identify our particular installation process.
- ''Set the main window title, read the background bitmap and display the
- ''window...
- i% = MoveWindow(hWnd%, 0, 0, GetScreenWidth(), GetScreenHeight(), 0)
- SetAbout szAbout1$, szAbout2$
- SetTitle szTitle$
- SetBitmap szCuiName$, LOGO
-
-
- ''Find out where the .INF file is, then read it...
- szInf$ = STRING$(144,0)
- szInf$ = GetSymbolValue("STF_SRCINFPATH")
-
- IF szInf$ = "" THEN
- szInfName$ = STRING$(16,0)
- i% = FAcquireString(STR_INFNAME, szInfName$, 16)
- szInf$ = GetSymbolValue("STF_CWDDIR") + szInfName$
- szInfName$ = STRING$(0,0)
- END IF
-
- ReadInfFile szInf$
- szInf$ = STRING$(0,0)
-
-
- '' add '[General]' and 'ExePath' to resource.h and cui.rc files
- szININame$ = STRING$(16,0)
- i% = FAcquireString(STR_ININAME, szININame, 16)
-
- IF (DoesFileExist(MakePath(gWINDIR$, szININame$), femExists) = 1) THEN
- ''Open the INI file
- ''Read the ExePath string
- ''Set szDestDir$ to that path
- END IF
- szININame$ = STRING$(0,0)
-
-
- '$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
-
-
-
- WELCOME:
- '' **********************
- '' *** Welcome dialog ***
- '' **********************
- sz$ = UIStartDlg(szCuiName$, DLG_WELCOME, "FWelcomeDlgProc", DLG_HELPWELCOME, gHELPPROC$)
-
- IF sz$ = "CONTINUE" THEN ''Continue button pressed
- UIPop 1
- GOTO CONFIRMINFO
-
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO WELCOME
-
- ELSE ''Handle Help and Exit buttons
- GOSUB ASKQUIT
- GOTO WELCOME
- END IF
-
-
-
- CONFIRMINFO: ''Initialize the Confirm Installation Settings dialog
- szSelGroup$ = GetSymbolValue("symSelectedGroup")
- szDestDir$ = GetSymbolValue("symDestDirectory")
-
- tmpStr$ = STRING$(64,0)
- i% = FAcquireString(STR_INSTALLPATH, tmpStr$, 64)
- ReplaceListItem "ConfirmTextIn", 1, tmpStr$+": "+szDestDir$
- i% = FAcquireString(STR_PROGMANGROUP, tmpStr$, 64)
- ReplaceListItem "ConfirmTextIn", 2, tmpStr$+": "+szSelGroup$
- tmpStr$ = STRING$(0,0)
-
- ''COULD ADD CODE TO CALCULATE HOW MUCH SPACE WILL BE REQUIRED BY THE FILES...
-
- CONFIRMINFO1:
- '' ********************************************
- '' *** Confirm Installation Settings dialog ***
- '' ********************************************
- sz$ = UIStartDlg(szCuiName$, DLG_CONFIRMINFO, "FConfirmDlgProc", 0, "")
-
- IF sz$ = "CONTINUE" THEN ''OK button pressed
- UIPop 1
- GOTO STARTINSTALL ''Skip over Path and Group Name dialogs
-
- ELSEIF sz$ = "BACK" THEN ''Change button pressed
- UIPop 1
- GOTO GETPATH ''Modify the Install Path...
-
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO CONFIRMINFO
-
- ELSE ''Why would we get here???
- GOSUB ASKQUIT
- GOTO CONFIRMINFO
- END IF
-
-
-
- GETPATH:
- '' SetSymbolValue "symDefaultDirectory", szDestDir$
- SetSymbolValue "symEditBoxFocus", "ALL"
-
- GETPATH1:
- '' ***********************************************
- '' *** Installation Directory Selection dialog ***
- '' ***********************************************
- sz$ = UIStartDlg(szCuiName$, DLG_DESTPATH, "FDestPathDlgProc", DLG_HELPDESTPATH, gHELPPROC$)
-
- szDestDir$ = GetSymbolValue("symDestDirectory") ''What's the path the user chose?
-
- IF sz$ = "CONTINUE" THEN ''Path chosen by the user
- IF IsDirWritable(szDestDir$) = 0 THEN
- GOSUB BADPATH ''Path isn't valid,
- GOTO GETPATH1 ''so try again...
- END IF
-
- UIPop 1 ''Close the dialog
-
- ''Calculate the available space for the new (or old) drive...
- szDestDisk$ = MID$(szDestDir$, 1, 1)
- FreeSpace& = GetFreeSpaceForDrive(szDestDisk$)
- IF (FreeSpace& < 0) THEN
- FreeSpace& = 0
- END IF
- SetSymbolValue "symSpaceAvail", STR$(FreeSpace& / 1024) + " K"
-
- '' Choose the appropriate ProgMan Group Name handler...
- IF ListMade% = 0 THEN ''Get the Group Name for icon(s)
- GOTO GETGROUPNAME ''Don't reinitialize Group Name list
- ELSE
- GOTO GETGROUPNAME1 ''Initialize the ProgMan Group Name list
- END IF
-
- ELSEIF sz$ = "BACK" THEN ''Back button pressed
- UIPop 1
- GOTO CONFIRMINFO ''Must not REALLY want to modify defaults
-
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO GETPATH1
-
- ELSE ''Why would we get here???
- GOSUB ASKQUIT
- GOTO GETPATH
- END IF
-
-
-
- GETGROUPNAME: ''Initialize the ProgMan Group Name list...
- IF ListMade% = 0 THEN
- ListMade% = 1
- AddListItem "ListGroupsIn", szSelGroup$
- END IF
-
- SetSymbolValue "symGroupListOut", szSelGroup$
-
- GETGROUPNAME1:
- '' *******************************************
- '' *** Select Program Manager Group dialog ***
- '' *******************************************
- sz$ = UIStartDlg(szCuiName$, DLG_GROUPNAME, "FGroupNameDlgProc", DLG_HELPGROUPNAME, gHELPPROC$)
-
- szSelGroup$ = GetSymbolValue("EditGroupOut")
- SetSymbolValue "symSelectedGroup", szSelGroup$
-
- IF sz$ = "CONTINUE" THEN ''Continue button pressed
- UIPop 1
- GOTO CONFIRMINFO ''Loop back to the top for verification...
-
- ELSEIF sz$ = "BACK" THEN ''Back button pressed
- UIPop 1
- GOTO GETPATH
-
- ELSEIF sz$ = "EXIT" THEN ''Exit button pressed
- '' UIPop 1
- GOSUB ASKQUIT
- GOTO GETGROUPNAME1
-
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO GETGROUPNAME1
-
- ELSE ''Why would we ever get here?
- UIPop 1
- GOSUB ASKQUIT
- GOTO GETGROUPNAME1
- END IF
-
-
-
- STARTINSTALL: ''Do the installation (copy the files and stuff like that)...
- Install
-
-
-
- QUIT:
- ON ERROR GOTO ERRQUIT
- dlg% = 0
-
- ''ERR is an MS Test variable with the following definition from the MS Test
- ''documentation: "The ERR variable is a global integer containing the
- ''error code of the last trappable run-time error that occurred."
-
- IF ERR = 0 THEN ''Everything worked fine...
- dlg% = DLG_EXITSUCCESS
- ShowReadme% = 1
-
- ELSEIF ERR = STFQUIT THEN ''setupapi.inc pre-defined error level
- dlg% = DLG_ERRSETUPFAILED
- ShowReadme% = 0
-
- ELSE ''Something bad happened...
- dlg% = DLG_ERRSETUPFAILED
- ShowReadme% = 0
- END IF
-
- QUIT1:
- '' *********************************************************************
- '' The dialog that's displayed depends on the value of dlg% set in QUIT:
- '' *********************************************************************
- sz$ = UIStartDlg(szCuiName$, dlg%, "FNoExitButtonDlgProc", 0, "")
-
- IF sz$ = "REACTIVATE" THEN
- GOTO QUIT1
- END IF
-
- UIPop 1
-
- IF ShowReadme% = 1 THEN
- GOTO README
- ELSE
- GOTO ALL_DONE
- END IF
-
-
-
-
- README: '' Show the readme file
- IF (1 = DoesFileExist(MakePath(szDestDir$, szReadme$), femExists)) THEN
- RUN szNotepad$+" "+MakePath(szDestDir$, szReadme$), NOWAIT
- END IF
-
-
-
-
- ALL_DONE:
- END ''This is the exit point for the script
-
-
-
-
- ERRQUIT:
- i% = FAcquireString(ERR_CORRUPTSOURCES, errStr$, 144)
- i% = DoMsgBox(errStr$, szTitle$, DlgMode%)
- GOTO ALL_DONE
-
-
-
- BADPATH:
- '' **********************************************
- '' *** Unknown Path or Directory Error dialog ***
- '' **********************************************
- sz$ = UIStartDlg(szCuiName$, DLG_ERRBADPATH, "FNoExitButtonDlgProc", 0, "")
-
- IF sz$ = "REACTIVATE" THEN
- GOTO BADPATH
-
- ELSE
- UIPop 1
- END IF
-
- RETURN
-
-
-
- ASKQUIT:
- '' *******************************
- '' *** Incomplete Setup dialog ***
- '' *******************************
- sz$ = UIStartDlg(szCuiName$, DLG_EXITINCOMPLETE, "FExitIncompleteDlgProc", 0, "")
-
- IF sz$ = "EXIT" THEN ''Pressed the "Quit" button
- UIPopAll
- ERROR STFQUIT
-
- ELSEIF sz$ = "REACTIVATE" THEN
- GOTO ASKQUIT
-
- ELSE
- UIPop 1 ''Pressed the "Back" button--Pop the error alert
- END IF
-
- RETURN
-
-
- '' ****************************************
- '' ********** END OF MAIN SCRIPT **********
- '' ****************************************
-
-
-
-
- '*************************************************************************
- '** Routine: Install
- '**
- '** Purpose: Builds the copy list and performs all installation operations.
- '**
- '** Arguments:
- '** none.
- '**
- '** Returns: None.
- '**
- '** History:
- '** 940612 klb Inherited from Microsoft Windows v3.1 SDK (SAMPLE1.MST)
- '**
- '*************************************************************************
- SUB Install STATIC
-
- szDestDir$ = STRING$(144,0)
- szSrcDir$ = STRING$(144,0)
- szSelGroup$ = STRING$(64,0)
-
- szSrcDir$ = GetSymbolValue("STF_SRCDIR")
- szDestDir$ = GetSymbolValue("symDestDirectory")
- szSelGroup$ = GetSymbolValue("symSelectedGroup")
-
- CreateDir szDestDir$, cmoNone
-
- '$IFDEF DEBUG
- OpenLogFile MakePath(szDestDir$, "LOGFILE.OUT"), 0
- WriteToLogFile ""
- WriteToLogFile " User chose as destination directory: '" + szDestDir$ + "'"
- '' WriteToLogFile " User chose option: '" + OPTCUR$ + "'"
- WriteToLogFile ""
- WriteToLogFile "May have had to create the directory: " + szDestDir$
- WriteToLogFile ""
- '$ENDIF
-
- AddSectionFilesToCopyList "Files", szSrcDir$, szDestDir$
- CopyFilesInCopyList
-
- szName$ = STRING$(32,0)
- szReadme$ = STRING$(16,0)
- szNotepad$ = STRING$(16,0)
- szHPCopier$ = STRING$(16,0)
-
- i% = FAcquireString(STR_NAME, szName$, 32)
- i% = FAcquireString(STR_README, szReadme$, 16)
- i% = FAcquireString(STR_NOTEPAD, szNotepad$, 16)
- i% = FAcquireString(STR_HPCOPIER, szHPCopier$, 16)
-
- CreateProgmanGroup szSelGroup, "", cmoNone
- ShowProgmanGroup szSelGroup, 1, cmoNone
- CreateProgmanItem szSelGroup, szName$, MakePath(szDestDir$,szHPCopier$), "", cmoOverwrite
- CreateProgmanItem szSelGroup, szReadme$, szNotepad$+" "+MakePath(szDestDir$,szReadme$), "", cmoOverwrite
-
- szName$ = STRING$(0,0)
- szReadme$ = STRING$(0,0)
- szNotepad$ = STRING$(0,0)
- szHPCopier$ = STRING$(0,0)
- szDestDir$ = STRING$(0,0)
- szSelGroup$ = STRING$(0,0)
- szSrcDir$ = STRING$(0,0)
-
- '$IFDEF DEBUG
- CloseLogFile
- '$ENDIF
-
- END SUB
-
-
-
- '*************************************************************************
- '** Routine: FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING
- '**
- '** 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.
- '**
- '** History:
- '** 940612 klb Inherited from Microsoft Windows v3.1 SDK (SAMPLE1.MST)
- '*************************************************************************
- 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
-
-