//////////////////////////////////////////////////////////////////////////////// // // IIIIIII SSSSSS // II SS InstallShield (R) // II SSSSSS (c) 1996-1997, InstallShield Software Corporation // II SS (c) 1990-1996, InstallShield Corporation // IIIIIII SSSSSS All Rights Reserved. // // // This code is generated as a starting setup template. You should // modify it to provide all necessary steps for your setup. // // // File Name: Setup.rul // // Description: InstallShield script // // Comments: This template script performs a basic setup on a // Windows 95 or Windows NT 4.0 platform. With minor // modifications, this template can be adapted to create // new, customized setups. // //////////////////////////////////////////////////////////////////////////////// // Include header file #include "sdlang.h" #include "sddialog.h" ////////////////////// string defines //////////////////////////// #define UNINST_LOGFILE_NAME "Uninst.isu" #define BOINC_GUI_EXE "boinc_gui.exe" #define README_TXT "readme.txt" //////////////////// installation declarations /////////////////// // ----- DLL prototypes ----- // your DLL prototypes // ---- script prototypes ----- // generated prototype ShowDialogs(); prototype MoveFileData(); prototype HandleMoveDataError( NUMBER ); prototype ProcessBeforeDataMove(); prototype ProcessAfterDataMove(); prototype SetupRegistry(); prototype SetupFolders(); prototype SetupStartupIcon(); prototype DisableLaunchBoincAtStartup(); prototype CleanUpInstall(); prototype SetupInstall(); prototype SetupScreen(); prototype CheckRequirements(); prototype DialogShowSdWelcome(); prototype DialogShowSdLicense(); prototype DialogShowSdAskDestPath(); prototype DialogShowSdSelectFolder(); prototype DialogShowSdSelectLanguage(); prototype DialogShowSdFinishReboot(); // your prototypes // ----- global variables ------ // generated BOOL bWinNT, bIsShellExplorer, bInstallAborted, bIs32BitSetup; STRING svDir; STRING svName, svCompany, svSerial; STRING szAppPath; STRING svSetupType; STRING svAppPath; // your global variables NUMBER bLaunchBoinc, bLaunchBoincAtStartup; //bViewReadme /////////////////////////////////////////////////////////////////////////////// // // MAIN PROGRAM // // The setup begins here by hiding the visible setup // window. This is done to allow all the titles, images, etc. to // be established before showing the main window. The following // logic then performs the setup in a series of steps. // /////////////////////////////////////////////////////////////////////////////// program Disable( BACKGROUND ); CheckRequirements(); SetupInstall(); SetupScreen(); if (ShowDialogs()<0) goto end_install; if (ProcessBeforeDataMove()<0) goto end_install; if (MoveFileData()<0) goto end_install; if (ProcessAfterDataMove()<0) goto end_install; if (SetupRegistry()<0) goto end_install; if (SetupFolders()<0) goto end_install; end_install: CleanUpInstall(); // If an unrecoverable error occurred, clean up the partial installation. // Otherwise, exit normally. if (bInstallAborted) then abort; endif; /*if (bViewReadme) then ChangeDirectory(TARGETDIR); svAppPath = TARGETDIR ^ README_TXT; LongPathToQuote( svAppPath, TRUE ); LaunchApp( "notepad", svAppPath ); endif;*/ if (bLaunchBoincAtStartup) then SetupStartupIcon(); else DisableLaunchBoincAtStartup(); endif; if (bLaunchBoinc) then ChangeDirectory(TARGETDIR); svAppPath = TARGETDIR ^ BOINC_GUI_EXE; LongPathToQuote( svAppPath, TRUE ); LaunchApp( svAppPath, "" ); endif; endprogram /////////////////////////////////////////////////////////////////////////////// // // // Function: ShowDialogs // // // // Purpose: This function manages the display and navigation // // the standard dialogs that exist in a setup. // // // /////////////////////////////////////////////////////////////////////////////// function ShowDialogs() NUMBER nResult; begin Dlg_Start: // beginning of dialogs label Dlg_SdWelcome: nResult = DialogShowSdWelcome(); if (nResult = BACK) goto Dlg_Start; Dlg_SdLicense: nResult = DialogShowSdLicense(); if (nResult = BACK) goto Dlg_SdWelcome; Dlg_SdAskDestPath: nResult = DialogShowSdAskDestPath(); if (nResult = BACK) goto Dlg_SdLicense; Dlg_SdSelectFolder: nResult = DialogShowSdSelectFolder(); if (nResult = BACK) goto Dlg_SdAskDestPath; // Added by Eric 01/23/03 //Dlg_SdSelectLanguage: // nResult = DialogShowSdSelectLanguage(); // if (nResult = BACK) goto Dlg_SdSelectFolder; return 0; end; /////////////////////////////////////////////////////////////////////////////// // // // Function: ProcessBeforeDataMove // // // // Purpose: This function performs any necessary operations prior to the // // actual data move operation. // // // /////////////////////////////////////////////////////////////////////////////// function ProcessBeforeDataMove() STRING svLogFile; NUMBER nResult, count; HWND client_win; begin InstallationInfo( @COMPANY_NAME, @PRODUCT_NAME, @PRODUCT_VERSION, @PRODUCT_KEY ); svLogFile = UNINST_LOGFILE_NAME; nResult = DeinstallStart( svDir, svLogFile, @UNINST_KEY, 0 ); if (nResult < 0) then MessageBox( @ERROR_UNINSTSETUP, WARNING ); endif; #define WM_DESTROY 2 // TODO: add boinc_cli.exe check to this // if boinc_gui.exe instance is running, tell it to quit client_win = FindWindow( "BOINCWindowClass", "" ); if (client_win != 0) then // Send message to PARENT window to quit SendMessage(client_win, WM_DESTROY, 0, 0); for count = 1 to 5 // Wait up to 5 seconds for client to quit client_win = FindWindow( "BOINCWindowClass", "" ); if (client_win != 0) then Delay(1); endif; endfor; client_win = FindWindow( "BOINCWindowClass", "" ); if (client_win != 0) then // Couldn't kill the old client MessageBox( "A BOINC client is still running on this \nsystem. You must close it before installing \na new version. Right click the blue \nBOINC icon, select Exit, and then \nrun this installer again.", SEVERE ); abort; endif; endif; szAppPath = TARGETDIR; // TODO : if your application .exe is in a subdir of TARGETDIR then add subdir if ((bIs32BitSetup) && (bIsShellExplorer)) then RegDBSetItem( REGDB_APPPATH, szAppPath ); RegDBSetItem( REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY ); RegDBSetItem( REGDB_UNINSTALL_NAME, @UNINST_DISPLAY_NAME ); endif; // TODO : update any items you want to process before moving the data // return 0; end; /////////////////////////////////////////////////////////////////////////////// // // // Function: MoveFileData // // // // Purpose: This function handles the data movement for // // the setup. // // // /////////////////////////////////////////////////////////////////////////////// function MoveFileData() NUMBER nResult, nDisk; begin nDisk = 1; SetStatusWindow( 0, "" ); Disable( DIALOGCACHE ); Enable( STATUS ); StatusUpdate( ON, 100 ); nResult = ComponentMoveData( MEDIA, nDisk, 0 ); HandleMoveDataError( nResult ); Disable( STATUS ); return nResult; end; /////////////////////////////////////////////////////////////////////////////// // // // Function: HandleMoveDataError // // // // Purpose: This function handles the error (if any) during the move data // // operation. // // // /////////////////////////////////////////////////////////////////////////////// function HandleMoveDataError( nResult ) STRING szErrMsg, svComponent , svFileGroup , svFile; begin svComponent = ""; svFileGroup = ""; svFile = ""; switch (nResult) case 0: return 0; default: ComponentError ( MEDIA , svComponent , svFileGroup , svFile , nResult ); szErrMsg = @ERROR_MOVEDATA + "\n\n" + @ERROR_COMPONENT + " " + svComponent + "\n" + @ERROR_FILEGROUP + " " + svFileGroup + "\n" + @ERROR_FILE + " " + svFile; SprintfBox( SEVERE, @TITLE_CAPTIONBAR, szErrMsg, nResult ); bInstallAborted = TRUE; return nResult; endswitch; end; /////////////////////////////////////////////////////////////////////////////// // // // Function: ProcessAfterDataMove // // // // Purpose: This function performs any necessary operations needed after // // all data has been moved. // // // /////////////////////////////////////////////////////////////////////////////// function ProcessAfterDataMove() begin // TODO : update self-registered files and other processes that // should be performed after the data has been moved. return 0; end; /////////////////////////////////////////////////////////////////////////////// // // // Function: SetupRegistry // // // // Purpose: This function makes the registry entries for this setup. // // // /////////////////////////////////////////////////////////////////////////////// function SetupRegistry() NUMBER nResult; STRING svPath; STRING svArgPath; STRING svDir; STRING svSoftwareStr; begin // TODO : Add all your registry entry keys here // // // RegDBCreateKeyEx, RegDBSetKeyValueEx.... // //nResult = CreateRegistrySet( "" ); svPath = TARGETDIR ^ BOINC_GUI_EXE; svArgPath = "\"" + TARGETDIR ^ BOINC_GUI_EXE + "\" -min"; svDir = TARGETDIR; if ( bWinNT ) then nResult = RegDBSetDefaultRoot (HKEY_CURRENT_USER); nResult = RegDBSetKeyValueEx ("Software\\Microsoft\\Windows\\CurrentVersion\\Run", "boincclient", REGDB_STRING, svArgPath, -1); nResult = RegDBCreateKeyEx ("Software\\BOINC", "ClientPath"); nResult = RegDBSetKeyValueEx ("Software\\BOINC", "ClientPath", REGDB_STRING, svPath, -1); nResult = RegDBCreateKeyEx ("Software\\BOINC", "ClientDir"); nResult = RegDBSetKeyValueEx ("Software\\BOINC", "ClientDir", REGDB_STRING, svDir, -1); svPath = WINDIR; LongPathToQuote( svPath, TRUE ); nResult = RegDBCreateKeyEx ("Software\\BOINC", "WinDir"); nResult = RegDBSetKeyValueEx ("Software\\BOINC", "WinDir", REGDB_STRING, svPath, -1); else nResult = RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE); nResult = RegDBSetKeyValueEx ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", "boincclient", REGDB_STRING, svArgPath, -1); nResult = RegDBCreateKeyEx ("SOFTWARE\\BOINC", "ClientPath"); nResult = RegDBSetKeyValueEx ("SOFTWARE\\BOINC", "ClientPath", REGDB_STRING, svPath, -1); nResult = RegDBCreateKeyEx ("SOFTWARE\\BOINC", "ClientDir"); nResult = RegDBSetKeyValueEx ("SOFTWARE\\BOINC", "ClientDir", REGDB_STRING, svDir, -1); svPath = WINDIR; LongPathToQuote( svPath, TRUE ); nResult = RegDBCreateKeyEx ("SOFTWARE\\BOINC", "WinDir"); nResult = RegDBSetKeyValueEx ("SOFTWARE\\BOINC", "WinDir", REGDB_STRING, svPath, -1); endif; // Set default screen saver //if ( bWinNT ) then //svPath = WINDIR ^ "sstest.scr"; //LongPathToQuote( svPath, TRUE ); //nResult = RegDBSetDefaultRoot (HKEY_CURRENT_USER); //nResult = RegDBSetKeyValueEx ("Control Panel\\Desktop", "SCRNSAVE.EXE", REGDB_STRING, svPath, -1); //else //svPath = WINDIR ^ "system.ini"; //LongPathToQuote ( svPath, TRUE ); //nResult = ConfigFileLoad ( svPath ); //nResult = ConfigAdd ("myscrnsave.exe", "myownpath", "SCRNSAVE.EXE", AFTER ); //nResult = ConfigFileSave ( svPath ); //endif; return nResult; end; /////////////////////////////////////////////////////////////////////////////// // // Function: SetupFolders // // Purpose: This function creates all the folders and shortcuts for the // setup. This includes program groups and items for Windows 3.1. // /////////////////////////////////////////////////////////////////////////////// function SetupFolders() NUMBER nResult; STRING svPath; STRING szProgram; begin // Added by Eric 11/12/02 svPath = TARGETDIR ^ BOINC_GUI_EXE; LongPathToQuote ( svPath , TRUE ); AddFolderIcon ( SHELL_OBJECT_FOLDER , "BOINC" , svPath , TARGETDIR , "" , 0 , "" , REPLACE ); // Added by Eric 12/12/02 svPath = TARGETDIR ^ UNINST_LOGFILE_NAME; LongPathToQuote ( svPath , TRUE ); szProgram = UNINST; szProgram = szProgram + " -f" + svPath; AddFolderIcon ( SHELL_OBJECT_FOLDER , "Remove BOINC" , szProgram , WINDIR , "" , 0 , "" , REPLACE ); // Added by Eric 01/27/03 svPath = TARGETDIR ^ README_TXT; LongPathToQuote ( svPath , TRUE ); AddFolderIcon ( SHELL_OBJECT_FOLDER , "BOINC help" , svPath , WINDIR , "" , 0 , "" , REPLACE ); // TODO : Add all your folder (program group) along with shortcuts (program items) // // // CreateProgramFolder, AddFolderIcon.... // nResult = CreateShellObjects( "" ); return nResult; end; /////////////////////////////////////////////////////////////////////////////// // // Function: SetupStartupIcon // // Purpose: This function places a shortcut to the boinc client in the // Startup menu folder. // /////////////////////////////////////////////////////////////////////////////// function SetupStartupIcon() STRING svPath; STRING szProgram; begin // added by Karl 2003-10-27 svPath = TARGETDIR ^ BOINC_GUI_EXE; LongPathToQuote ( svPath , TRUE ); szProgram = svPath + " -min"; AddFolderIcon( FOLDER_STARTUP, "BOINC", szProgram, TARGETDIR, "", 0, "", REPLACE); return 0; end; /////////////////////////////////////////////////////////////////////////////// // // Function: DisableLaunchBoincAtStartup // // Purpose: This function removes any registry entries and/or Startup menu // shortcuts that cause boinc to launch at system start. This is // needed to handle the case where the user previously installed // boinc with the option to launch at startup, them (re-)installs // boinc without the option to launch at startup. // /////////////////////////////////////////////////////////////////////////////// function DisableLaunchBoincAtStartup() NUMBER nResult; STRING szKSuffix; // the constant part of the registry key STRING szKey; // registry key to lookup STRING szValue; // registry key value to delete begin // added by gmg 2003-12-15 szValue = "boincclient"; szKSuffix = "\\Microsoft\\Windows\\CurrentVersion\\Run"; // delete any Startup folder icons // this is normally what controls autostart nResult = DeleteFolderIcon( FOLDER_STARTUP, "BOINC" ); // now, delete any startup info in the registry // not sure what the "boincclient" value does. It is deleted // as soon as boinc autostarts for the first time (either as // a result of "Start Boinc Now" or the first autostart after // a (re)boot. // anyway, it should be removed if it exists, as doing so doesn't // seem to hurt anything. // NT registry key as defined by SetupRegistry() nResult = RegDBSetDefaultRoot (HKEY_CURRENT_USER); szKey = "Software" + szKSuffix; nResult = RegDBDeleteValue ( szKey, szValue ); // non-NT registry key as defined by SetupRegistry() nResult = RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE); szKey = "SOFTWARE" + szKSuffix; nResult = RegDBDeleteValue ( szKey, szValue ); return 0; end; /////////////////////////////////////////////////////////////////////////////// // // // Function: CleanUpInstall // // // // Purpose: This cleans up the setup. Anything that should // // be released or deleted at the end of the setup should // // be done here. // // // /////////////////////////////////////////////////////////////////////////////// function CleanUpInstall() begin if (bInstallAborted) then return 0; endif; DialogShowSdFinishReboot(); if (BATCH_INSTALL) then // ensure locked files are properly written CommitSharedFiles(0); endif; return 0; end; /////////////////////////////////////////////////////////////////////////////// // // // Function: SetupInstall // // // // Purpose: This will setup the installation. Any general initialization // // needed for the installation should be performed here. // // // /////////////////////////////////////////////////////////////////////////////// function SetupInstall() begin Enable( CORECOMPONENTHANDLING ); bInstallAborted = FALSE; if (bIs32BitSetup) then svDir = PROGRAMFILES ^ @PRODUCT_NAME; else svDir = PROGRAMFILES ^ @PRODUCT_NAME16; // use shorten names endif; TARGETDIR = svDir; SdProductName( @PRODUCT_NAME ); Enable( DIALOGCACHE ); return 0; end; /////////////////////////////////////////////////////////////////////////////// // // // Function: SetupScreen // // // // Purpose: This function establishes the screen look. This includes // // colors, fonts, and text to be displayed. // // // /////////////////////////////////////////////////////////////////////////////// function SetupScreen() begin Enable( FULLWINDOWMODE ); Enable( INDVFILESTATUS ); SetTitle( @TITLE_MAIN, 24, WHITE ); SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION ); // Caption bar text. Enable( BACKGROUND ); Delay( 1 ); end; /////////////////////////////////////////////////////////////////////////////// // // // Function: CheckRequirements // // // // Purpose: This function checks all minimum requirements for the // // application being installed. If any fail, then the user // // is informed and the setup is terminated. // // // /////////////////////////////////////////////////////////////////////////////// function CheckRequirements() NUMBER nvDx, nvDy, nvResult; STRING svResult; begin bWinNT = FALSE; bIsShellExplorer = FALSE; // Check screen resolution. GetExtents( nvDx, nvDy ); if (nvDy < 480) then MessageBox( @ERROR_VGARESOLUTION, WARNING ); abort; endif; // set 'setup' operation mode bIs32BitSetup = TRUE; GetSystemInfo( ISTYPE, nvResult, svResult ); if (nvResult = 16) then bIs32BitSetup = FALSE; // running 16-bit setup return 0; // no additional information required endif; // --- 32-bit testing after this point --- // Determine the target system's operating system. GetSystemInfo( OS, nvResult, svResult ); if (nvResult = IS_WINDOWSNT) then // Running Windows NT. bWinNT = TRUE; // Check to see if the shell being used is EXPLORER shell. if (GetSystemInfo( OSMAJOR, nvResult, svResult ) = 0) then if (nvResult >= 4) then bIsShellExplorer = TRUE; endif; endif; elseif (nvResult = IS_WINDOWS95 ) then bIsShellExplorer = TRUE; endif; end; /////////////////////////////////////////////////////////////////////////////// // // // Function: DialogShowSdWelcome // // // // Purpose: This function handles the standard welcome dialog. // // // // // /////////////////////////////////////////////////////////////////////////////// function DialogShowSdWelcome() NUMBER nResult; STRING szTitle, szMsg; begin szTitle = ""; szMsg = ""; nResult = SdWelcome( szTitle, szMsg ); return nResult; end; /////////////////////////////////////////////////////////////////////////////// // // // Function: DialogShowSdLicense // // // // Purpose: This function displays the license agreement dialog. // // // // // /////////////////////////////////////////////////////////////////////////////// function DialogShowSdLicense() NUMBER nResult; STRING szTitle, szMsg, szQuestion, szLicenseFile; begin szLicenseFile = SUPPORTDIR ^ "license.txt"; szTitle = ""; szMsg = ""; szQuestion = ""; nResult = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile ); return nResult; end; /////////////////////////////////////////////////////////////////////////////// // // // Function: DialogShowSdAskDestPath // // // // Purpose: This function asks the user for the destination directory. // // // /////////////////////////////////////////////////////////////////////////////// function DialogShowSdAskDestPath() NUMBER nResult; STRING szTitle, szMsg; begin szTitle = ""; szMsg = ""; nResult = SdAskDestPath( szTitle, szMsg, svDir, 0 ); TARGETDIR = svDir; return nResult; end; /////////////////////////////////////////////////////////////////////////////// // // // Function: DialogShowSdSelectFolder // // // // Purpose: This function displays the standard folder selection dialog. // // // // // /////////////////////////////////////////////////////////////////////////////// function DialogShowSdSelectFolder() NUMBER nResult; STRING szTitle, szMsg; begin if (SHELL_OBJECT_FOLDER = "") then SHELL_OBJECT_FOLDER = @FOLDER_NAME; endif; szTitle = ""; szMsg = ""; nResult = SdSelectFolder( szTitle, szMsg, SHELL_OBJECT_FOLDER ); return nResult; end; /////////////////////////////////////////////////////////////////////////////// // // // Function: DialogShowSdFinishReboot // // // // Purpose: This function will show the last dialog of the product. // // It will allow the user to reboot and/or show some readme text. // // // /////////////////////////////////////////////////////////////////////////////// function DialogShowSdFinishReboot() NUMBER nResult, nDefOptions; STRING szTitle, szMsg1, szMsg2, szOption1, szOption2; begin //if (!BATCH_INSTALL) then //bViewReadme = FALSE; bLaunchBoinc = TRUE; bLaunchBoincAtStartup = TRUE; szMsg1 = ""; szMsg2 = ""; szOption1 = "Run BOINC now"; szOption2 = "Run BOINC at Startup"; //szOption2 = "View README File"; nResult = SdFinish( szTitle, szMsg1, szMsg2, szOption1, szOption2, bLaunchBoinc, bLaunchBoincAtStartup ); return 0; //endif; nDefOptions = SYS_BOOTMACHINE; szTitle = ""; szMsg1 = ""; szMsg2 = ""; nResult = SdFinishReboot( szTitle, szMsg1, nDefOptions, szMsg2, 0 ); return nResult; end; /////////////////////////////////////////////////////////////////////////////// // // // Function: DialogShowSdSelectLanguage // // // // Purpose: This function displays the language selection dialog. // // Added by Eric Heien, 1/23/03 // // // /////////////////////////////////////////////////////////////////////////////// function DialogShowSdSelectLanguage() NUMBER nResult; STRING szTitle, szMsg1, szMsg2; STRING oldMedia; begin szTitle = "Select Language"; szMsg1 = "Please select the language you want the BOINC client to use:"; nResult = SdAskOptions(szTitle , szMsg1, "" , "" , "Language Files" , EXCLUSIVE); //nResult = SdComponentDialog(szTitle , szMsg1, TARGETDIR , "Language Files"); return nResult; end; // --- include script file section --- #include "sddialog.rul"