home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / WIN_CE / PC / powtoy.exe / setup.rul < prev   
Encoding:
Text File  |  1997-10-05  |  60.5 KB  |  1,593 lines

  1. /*++
  2.  
  3. ****************************************************************************************************
  4. ********  search for $MODIFY  - this will point to parts of the code that need modification ********
  5. ********  search for $ADDGAME - code needed to be modified to add a game                    ********
  6. ****************************************************************************************************
  7.  
  8.  
  9. Copyright (c) 1996 Microsoft Corp.
  10.  
  11. File Name:
  12.     
  13.     Setup.c (AppInstall)
  14.  
  15. Abstract:
  16.  
  17.     This is the interpreted script for use with InstallShield3, that is to be used to install
  18.     applications from the disk to the HPC.
  19.  
  20. Author:
  21.  
  22.     James Chen (jamesch) Feb 15/96
  23.     Slight modifications by Neil Enns (t-neile) July 96
  24.     Added multiple-component installation: Anthony Daniels, July 15th, 1996
  25.     Adapted gamepack for "hot" builds: Ido Ben-Shachar (idobs) August 20/96
  26.     Whoa, we have too many bugs.  Revamped multiple-component installation: Ido Ben-Shachar (idobs) 10/15/96
  27.  
  28. --*/
  29.  
  30. /*** application-specific constants ***/
  31.  
  32. // installation information
  33. #define SZ_COMPANY_NAME         "Microsoft"         // $MODIFY
  34. #define SZ_PRODUCT_NAME         "Microsoft Windows CE PowerToys" // $MODIFY
  35. #define SZ_PRODUCT_VERSION      "1.0"               // $MODIFY
  36. #define SZ_PRODUCT_KEY_1        "cascade.exe"       // $MODIFY - this must match your main executable name
  37. #define SZ_PRODUCT_KEY_2        "mute.exe"          // $MODIFY - this must match your main executable name
  38. #define SZ_PRODUCT_KEY_3        "ppaint.exe"        // $MODIFY - this must match your main executable name
  39.  
  40. #define SZ_PRODUCT_SUBF_1        "Cascade"       // $MODIFY - this must match your main executable name
  41. #define SZ_PRODUCT_SUBF_2        "Mute"          // $MODIFY - this must match your main executable name
  42. #define SZ_PRODUCT_SUBF_3        "Ppaint"        // $MODIFY - this must match your main executable name
  43.  
  44. #define SZ_ICON_FILE_1          "cascade.ico"       // Icon file for use in HPC Manager // BUGBUG: ido
  45. #define SZ_ICON_FILE_2          "mute.ico"          // Icon file for use in HPC Manager // BUGBUG: ido
  46. #define SZ_ICON_FILE_3          "ppaint.ico"        // Icon file for use in HPC Manager // BUGBUG: ido
  47.  
  48. // default values
  49. #define SZ_BITMAP_BACKGROUND    "pegpage.bmp"
  50. #define SZ_BITMAP_DIALOG        "dlg.bmp"
  51. #define SZ_SOURCE_FILE          "data.z"            // $MODIFY - compressed source file
  52. #define SZ_LICENSE_TEXT         "license.txt"        // $MODIFY - the license agreement
  53.  
  54. #define SZ_DEFAULT_DESKTOP_LOCATION     "\\Program Files\\HPC Explorer\\HPC Applications\\PowerToys" // $MODIFY
  55. #define SZ_INSTALL_SUBDIR               "\\HPC Applications\\PowerToys" // $MODIFY
  56. #define SZ_DEST_DIR_PEGASUS     "\\Program Files\\Accessories"    // $MODIFY - default dest dir on the HPC
  57.  
  58. // unintall information
  59. #define SZ_DEINSTALL_KEY        "PowerToys"         // $MODIFY // Uninstall key on DESKTOP side
  60. #define SZ_UNINSTALL_NAME       "PowerToys v1.0 (Remove Only)"    // $MODIFY Uninstall name on DESKTOP side
  61.  
  62. // Load filename to send to PegLoad
  63. //#define SZ_PEGLOAD_APPNAME      "Blackjack"         // $MODIFY - your app's 'home' registry key on the HPC
  64. //#define SZ_PEGLOAD_LOADFILE     "blackjack.load"    // $MODIFY - your app's .LOAD file // BUGBUG: ido
  65.  
  66. // the HPC Manager name
  67. #define SZ_MINERVA_NAME         "HPC Explorer"
  68.  
  69. // to find the load file data for PPCLOAD.DLL, look in the registry for the path for Minerva
  70. #define SZ_REGKEY_MINERVA_LOCATION  "\\Software\\Microsoft\\Pegasus"   // in HKEY_LOCAL_MACHINE
  71. #define SZ_REGVAL_MINERVA_LOCATION  "InstalledDir"
  72. #define SZ_PEGLOAD_DLL          "ppcload.dll"
  73. #define szPRIVATE_HELPER_DLL        "delval.dll"        // main helper DLL with assorted functions
  74.  
  75.  
  76. // variables for the remote control start menu item on the PC
  77. #define szREMOTE_CONTROL_FOLDER         "Handheld PC Remote Control"        // remote control folder name
  78. #define szREMOTE_CONTROL_EXE            "\\Rcontrol\\remhpc.exe"                // remote control helper app
  79. #define szREMOTE_CONTROL_DOC            "\\Rcontrol\\remhpc.doc"                // remote control doc
  80. #define szREMOTE_CONTROL_FOLDER_EXE     "Handheld PC Remote Control"        // remote control name
  81. #define szREMOTE_CONTROL_FOLDER_DOC     "Readme"                    // remote control doc name
  82.  
  83.  
  84. // hard disk space required
  85. #define cEXTRA_SPACE_REQUIRED     205824  // $MODIFY - extra space needed during the decompression to the desktop, in bytes
  86.  
  87. // error codes returned to appinstall program - taken from PEGLOAD\ERR.H
  88. #define LOAD_SUCCESS            0
  89. #define LOAD_OUTOFSTORAGE       1   // out of memory on the Pegasus
  90. #define LOAD_CANCELLEDBYUSER    2   // loading cancelled by the user
  91. #define LOAD_INVALID_PARAMETER  3   // invalid parameter in the command line parameters
  92. #define LOAD_FAILED             4   // generic load failure
  93. #define LOAD_FAILEDCANTCLEANUP  5   // load failure, and cannot clean-up what was done to the Pegasus
  94. #define LOAD_DISCONNECTED       6   // disconnection in communications
  95. #define LOAD_CANT_CREATE_DIR    7   // cannot create the destination directory
  96. #define LOAD_REG_ERROR          8   // cannot create the registry entry
  97. #define LOAD_ERROR              9   // Unknown error
  98.  
  99. // Dialog titles
  100. #define SZ_TITLE_LICENSE        "Software License Agreement"
  101.  
  102. // Dialog strings
  103. #define SZ_MSG_LICENSE          "Please read the following license agreement.  Use the scroll bar to view the rest of this agreement."
  104. #define SZ_MSG_AGREEMENT        "Do you accept all the terms of the preceeding license agreement?  If so, click on the Yes push button.  If you select No, Setup will exit."
  105.  
  106. declare
  107.  
  108. #include "sddialog.h"   // include script dialog definitions
  109.  
  110.     /*** local variables to main program ***/
  111.     HWND g_hwnd;
  112.     
  113.     NUMBER  nTotalFileSize;     // total file size of the application
  114.     NUMBER  nResult;            // result of a function call
  115.  
  116.     STRING  szDestDirDesktop;   // destination directory on the desktop
  117.     STRING  szDestDirPegasus;   // destination directory on the Pegasus
  118.  
  119.     STRING  szUserName;         // register the user's name
  120.     STRING  szUserCompany;      // register the user's company
  121.  
  122.     STRING  szUninstLogFile;    // uninstall logfile created by InstallShield
  123.     STRING  szFileSet;          // the file set used for copying the files
  124.  
  125.     STRING  szPegasusCPU;       // string specifying Pegasus CPU type
  126.  
  127.     STRING  szPathname;         // path to the license agreement file
  128.  
  129.     STRING  g_szDllFilename;    // ppcload.dll filename
  130.     STRING  g_szDllFilename1;    // ppcload.dll filename
  131.  
  132.     // List of file extensions used in all the components except those ending with the CPU type.
  133.     LIST    g_listFileExtensions;
  134.  
  135.     // Information about the components:
  136.     LIST    g_listComponentNames,            // The names that appear in the selection box
  137.             g_listComponentSizes,            // Sizes of each component
  138.             g_listComponentDirectories,        // Directories of the components in the compressed data file.
  139.             g_listComponentsToInstall,        // Boolean list of which components to install (0 or 1 for each element)
  140.             g_listComponentPPCLoadFile,        // .load filename for each component
  141.             g_listComponentUninstallName;    // Name to display in add/remove programs on the HPC
  142.  
  143.  
  144.     /*** function declarations ***/
  145.     prototype   InitializeVariables();
  146.     prototype    InitializeComponentVars();
  147.     prototype    CleanUpComponentVars();
  148.     prototype   StripDoubleQuotes( BYREF STRING );
  149.     prototype   SetupScreen();
  150.     prototype   SetupWelcome();
  151.     prototype   DoSystemTest( BYREF STRING );
  152.     prototype   CheckForConflicts();
  153.     prototype       HWND USER.GetActiveWindow();
  154.     prototype       HWND USER.FindWindowEx( HWND, HWND, STRING, NUMBER );
  155.     // NOTE - the 4rd parameter of FindWindowEx is actually a LPSTR - however, InstallShield does not pass in
  156.     // a NULL string properly - and so, we will always pass 0 for the 3rd parameter to represent NULL
  157.  
  158.     prototype    CalculateComponentSizes();
  159.     prototype    NGetComponentFileSize( STRING, STRING );
  160.     prototype    NComponentSelection (STRING);
  161.     prototype   NGetTotalFileSize( STRING );
  162.     prototype   NRegisterUser( BYREF STRING, BYREF STRING );
  163.     prototype   NGetDestDesktop( BYREF STRING );
  164.     prototype   FCheckEnoughSpace( NUMBER, STRING );
  165.     prototype   NGetDestPegasus( BYREF STRING );
  166.     prototype   NGetCopyConfirmation( NUMBER, STRING, STRING );
  167.     prototype   CreateUninstallInfo( BYREF STRING, STRING );
  168.     prototype   SetupFileTransfer( BYREF STRING, STRING, STRING );
  169.     prototype   DoFileTransfer( STRING );
  170.     prototype   FinishSetup( NUMBER, STRING, STRING, STRING, STRING, STRING );
  171.             // FinishSetup also uses USER.GetActiveWindow()
  172.     prototype       BOOL   PPCLoad.Load_PegCpuType( POINTER );      // entry function to init LOAD in ppcload.dll
  173.     prototype       NUMBER PPCLoad.Load_Init();                     // entry function to init LOAD in PPCLOAD.DLL
  174.     prototype       NUMBER PPCLoad.Load_PegFreeSpace();             // entry function to init LOAD in PPCLOAD.DLL
  175.     prototype       BOOL   PPCLoad.Load_AlreadyInstalled( STRING ); // entry function to init LOAD in PPCLOAD.DLL
  176.     prototype       NUMBER PPCLoad.Load( HWND, STRING );    // entry function to call LOAD in PPCLOAD.DLL
  177.     prototype              PPCLoad.Load_Exit();             // entry function to exit LOAD in PPCLOAD.DLL
  178.     prototype               NUMBER PPCLOAD.Load_RegisterFileInfo( STRING, STRING, STRING, NUMBER); // Register icons with PegMan
  179.  
  180.     // get the Windows desktop/startup directories
  181.     prototype BOOL   delval.FGetDesktopDirectory( HWND, STRING );
  182.     prototype BOOL   delval.FGetStartupDirectory( HWND, STRING );
  183.     STRING  szFOLDER_DESKTOP[ 260 ];  // desktop folder name (of size MAX_PATH)
  184.     STRING  szFOLDER_STARTUP[ 260 ];  // startup folder name (of size MAX_PATH)
  185.  
  186.  
  187.  
  188.     prototype        CleanUp();
  189.     prototype   InstallFilter();
  190.  
  191. /*** main program ***/
  192. program
  193.  
  194. StartProgram:
  195.     // initialize all variables and lists
  196.     InitializeVariables();
  197.  
  198.     // initialize variables for the components
  199.     InitializeComponentVars();
  200.  
  201.     // set up the initial screen and bitmap
  202.     SetupScreen();
  203.  
  204.     CheckForConflicts();
  205.  
  206.     // create the welcome dialog
  207. SetupWelcomePart:
  208.     SetupWelcome();
  209.  
  210.     // test the system requirements
  211.     DoSystemTest( szPegasusCPU );
  212.  
  213.     // Now that the CPU type has been determined (szPegasusCPU), calculate the sizes of the components
  214.     CalculateComponentSizes();
  215.  
  216. // license agreement
  217. LicenseDlg:
  218.     szPathname = SUPPORTDIR ^ SZ_LICENSE_TEXT;
  219.     nResult = SdLicense( SZ_TITLE_LICENSE, SZ_MSG_LICENSE, SZ_MSG_AGREEMENT, szPathname );
  220.     if ( BACK = nResult ) then
  221.         goto SetupWelcomePart;
  222.     endif;
  223.  
  224.     // register the user name and company
  225. RegisterUserPart:
  226.     if ( NRegisterUser( szUserName, szUserCompany ) = BACK ) then
  227.     goto LicenseDlg;
  228.     endif;
  229.  
  230.     // get the destination directory on the desktop
  231. GetDestDesktopPart:
  232.     if ( NGetDestDesktop( szDestDirDesktop ) = BACK ) then
  233.     goto RegisterUserPart;
  234.     endif;
  235.  
  236.     // get the destination directory on the Pegasus
  237.     /* Not doin' this in V1
  238. GetDestPegasusPart:
  239.     if ( NGetDestPegasus( szDestDirPegasus ) = BACK ) then
  240.     goto GetDestDesktopPart;
  241.     endif;
  242.     */
  243.  
  244. ComponentSelectionPart:
  245.     if ( NComponentSelection (szDestDirDesktop) = BACK) then
  246.     goto GetDestDesktopPart;
  247.     endif;
  248.  
  249.     // Hey, now that we chose components, we can finally do this...
  250.     // calculate the total file size.
  251.     nTotalFileSize = NGetTotalFileSize( szPegasusCPU );
  252.  
  253.     // check space requirements on desktop
  254.     if ( FCheckEnoughSpace( nTotalFileSize, szDestDirDesktop ) = FALSE ) then
  255.     goto ComponentSelectionPart;
  256.     endif;
  257.  
  258. /* I hate this. Maybe if the dialog wern't so *ugly* and intimidating... 
  259.     // confirm copy selection
  260.     if ( NGetCopyConfirmation( nTotalFileSize, szDestDirDesktop, szDestDirPegasus ) = BACK ) then
  261.     goto GetDestPegasusPart;
  262.     endif;
  263. */
  264.     // prepare de-installation information for the desktop
  265.     CreateUninstallInfo( szUninstLogFile, szDestDirDesktop );
  266.  
  267.     // prepare files to transfer
  268.     SetupFileTransfer( szFileSet, szDestDirDesktop, szPegasusCPU );
  269.  
  270.     // perform file transfer
  271.     DoFileTransfer( szFileSet );
  272.  
  273.     // The paint application needs a special bitmap filter installed
  274.     InstallFilter();
  275.  
  276.     // finish setup by using PPCLOAD.DLL to load the files to the Pegasus, and offer to read README file
  277.     FinishSetup( nTotalFileSize, szDestDirDesktop, szDestDirPegasus, szPegasusCPU, szUserName, szUserCompany );
  278.  
  279.     // perform cleanup of dynamically-allocated lists
  280.     CleanUp();
  281. exit;
  282.  
  283.  
  284.  
  285. /*++
  286.     InstallFilter:
  287.     - install 2bp->bmp filter
  288.  
  289.     Arguments: None
  290.  
  291.     Return Value: None
  292. --*/
  293. function InstallFilter()
  294.     NUMBER  nErr;
  295.     STRING  szPaintDir;
  296.     STRING    szMinervaLocation;
  297.     NUMBER    fInstallPaint;
  298.     NUMBER  nvRegType;
  299.     NUMBER  nvSize;
  300. begin
  301.     // Let's only install the filter if the paint application is being installed...
  302.     ListGetFirstString(g_listComponentDirectories, szPaintDir); // $MODIFY: Note that this isn't necessarily the first component in the list!
  303.     ListGetFirstItem(g_listComponentsToInstall, fInstallPaint);
  304.     if (1 = fInstallPaint) then
  305.         nErr = 0;            // no errors so far
  306.  
  307.         // Find out where minerva lives
  308.         RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
  309.         nErr = nErr + RegDBGetKeyValueEx("\\SOFTWARE\\Microsoft\\Pegasus", "InstalledDir", nvRegType,
  310.                 szMinervaLocation, nvSize);
  311.  
  312.         // Let's copy bmp.dll to a safer place, like the minerva directory!
  313.         SRCDIR = szDestDirDesktop ^ szPaintDir;
  314.         TARGETDIR = szMinervaLocation;
  315.         nErr = nErr + CopyFile("bmp.dll", "bmp.dll");
  316.  
  317.         // set default root
  318.         nErr = nErr + RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
  319.  
  320.         nErr = nErr + RegDBCreateKeyEx("\\SOFTWARE\\Microsoft\\Pegasus\\Filters\\.2bp", "");
  321.         nErr = nErr + RegDBCreateKeyEx("\\SOFTWARE\\Microsoft\\Pegasus\\Filters\\.2bp\\InstalledFilters", "");
  322.         nErr = nErr + RegDBSetKeyValueEx("\\SOFTWARE\\Microsoft\\Pegasus\\Filters\\.2bp", "DefaultExport", REGDB_STRING, "{8BC519B4-F935-11cf-9335-00AA006EC3AB}", -1);
  323.         nErr = nErr + RegDBSetKeyValueEx("\\SOFTWARE\\Microsoft\\Pegasus\\Filters\\.2bp\\InstalledFilters", "{8BC519B4-F935-11cf-9335-00AA006EC3AB}", REGDB_STRING, "", -1);
  324.  
  325.         // set default root
  326.         nErr = nErr + RegDBSetDefaultRoot( HKEY_CLASSES_ROOT );
  327.  
  328.         nErr = nErr + RegDBCreateKeyEx("\\CLSID\\{8BC519B4-F935-11cf-9335-00AA006EC3AB}", "");
  329.         nErr = nErr + RegDBCreateKeyEx("\\CLSID\\{8BC519B4-F935-11cf-9335-00AA006EC3AB}\\DefaultIcon", "");
  330.         nErr = nErr + RegDBCreateKeyEx("\\CLSID\\{8BC519B4-F935-11cf-9335-00AA006EC3AB}\\InProcServer32", "");
  331.         nErr = nErr + RegDBCreateKeyEx("\\CLSID\\{8BC519B4-F935-11cf-9335-00AA006EC3AB}\\PegasusFilter", "");
  332.         nErr = nErr + RegDBSetKeyValueEx("\\CLSID\\{8BC519B4-F935-11cf-9335-00AA006EC3AB}", "", REGDB_STRING, "Bitmap Image", -1);
  333.         nErr = nErr + RegDBSetKeyValueEx("\\CLSID\\{8BC519B4-F935-11cf-9335-00AA006EC3AB}\\DefaultIcon", "", REGDB_STRING, szMinervaLocation ^ "\\" ^ "bmp.dll,-1000", -1);
  334.         nErr = nErr + RegDBSetKeyValueEx("\\CLSID\\{8BC519B4-F935-11cf-9335-00AA006EC3AB}\\InProcServer32", "", REGDB_STRING, szMinervaLocation ^ "\\" ^ "bmp.dll", -1);
  335.         nErr = nErr + RegDBSetKeyValueEx("\\CLSID\\{8BC519B4-F935-11cf-9335-00AA006EC3AB}\\InProcServer32", "ThreadingModel", REGDB_STRING, "Apartment", -1);
  336.         nErr = nErr + RegDBSetKeyValueEx("\\CLSID\\{8BC519B4-F935-11cf-9335-00AA006EC3AB}\\PegasusFilter", "Description", REGDB_STRING, "Convert from Pocket Bitmap to Bitmap", -1);
  337.         nErr = nErr + RegDBSetKeyValueEx("\\CLSID\\{8BC519B4-F935-11cf-9335-00AA006EC3AB}\\PegasusFilter", "NewExtension", REGDB_STRING, "bmp", -1);
  338.  
  339.         // if any registry setting failed, put up a warning box
  340.         if ( 0 != nErr ) then
  341.             SetDialogTitle( DLG_MSG_WARNING, "Registry Settings Failed" );
  342.             MessageBox( "Setup could not install bitmap converter for the Paint Application.", WARNING );
  343.         endif;
  344.     endif;
  345. end;
  346.  
  347.  
  348.  
  349. /*++
  350.     
  351.     NComponentSelection:
  352.     - Allows the user to select the games they want to install.  Sets a
  353.       boolean flag for each game based on whether it is selected here or not.
  354.  
  355.     Arguments:
  356.  
  357.     Return value: NEXT or BACK.
  358.  
  359. --*/
  360. function NComponentSelection ( szDestDir )
  361.     
  362.     NUMBER nBackOrNext, nGameSize, nListResult, nInstall;
  363.     STRING szTitle, szMessage, szComponents, svGameName;
  364.     LIST listComponents;
  365.  
  366. begin
  367.     // Set up the parts of the component selection dialog.
  368.     szTitle = "Microsoft Windows CE PowerToys Installation!";        // $MODIFY
  369.     szMessage = "Select the components you wish to install";
  370.     szComponents = "Components";                        // $MODIFY
  371.     
  372.     // Put the components into the list, getting there names, sizes and
  373.     // whether to have them selected initially.
  374.     nListResult = ListGetFirstItem (g_listComponentSizes, nGameSize);
  375.     nListResult = ListGetFirstItem (g_listComponentsToInstall, nInstall);
  376.     nListResult = ListGetFirstString (g_listComponentNames, svGameName);    
  377.     while (END_OF_LIST != nListResult)
  378.         ComponentAddItem (szComponents, svGameName, nGameSize, nInstall);
  379.         nListResult = ListGetNextItem (g_listComponentSizes, nGameSize);
  380.         nListResult = ListGetNextItem (g_listComponentsToInstall, nInstall);
  381.         nListResult = ListGetNextString (g_listComponentNames, svGameName);
  382.     endwhile;
  383.  
  384.     // Display the components dialog.
  385.     nBackOrNext = SdComponentDialog (szTitle, szMessage, szDestDir, 
  386.                      szComponents);
  387.     
  388.     // Now work out which components the user selected and update the global
  389.     // variable g_listComponentsToInstall.
  390.     listComponents = ListCreate (STRINGLIST);
  391.     ComponentListItems (szComponents, listComponents);
  392.     nListResult = ListGetFirstItem (g_listComponentsToInstall, nInstall);
  393.     nListResult = ListGetFirstString (listComponents, svGameName);
  394.     while (END_OF_LIST != nListResult )
  395.         if (TRUE = ComponentIsItemSelected (szComponents, svGameName)) then
  396.             ListSetCurrentItem (g_listComponentsToInstall, 1);
  397.         else
  398.             ListSetCurrentItem (g_listComponentsToInstall, 0);
  399.         endif;
  400.         nListResult = ListGetNextItem (g_listComponentsToInstall, nInstall);
  401.         nListResult = ListGetNextString (listComponents, svGameName);
  402.  
  403.     endwhile;
  404.  
  405.     // Let's do our duty to keep things clean, and free up some variables!
  406.     ListDestroy(listComponents);
  407.  
  408.     return nBackOrNext;
  409. end;
  410.  
  411.  
  412.  
  413. /*++
  414.  
  415.     CalculateComponentSizes:
  416.     - figures out the sizes of all the components
  417.  
  418.     Arguments:
  419.     None
  420.  
  421.     Return Value:
  422.     None
  423. --*/
  424. function CalculateComponentSizes()
  425.     STRING    szDir;
  426.     NUMBER    nComponentSize;
  427.     NUMBER    nListResult;
  428.     NUMBER    nRetErr;
  429. begin
  430.     nRetErr = 0;            // no errors so far
  431.  
  432.     // First, we have to destroy the bogus list of component sizes we created earlier.  It was simply a placeholder
  433.     // so that Cleanup() could destroy a list, and so that this function could be called multiple times (being
  434.     // able to destroy the old list).
  435.     ListDestroy(g_listComponentSizes);
  436.  
  437.     // Now create the new list
  438.     g_listComponentSizes = ListCreate(NUMBERLIST);
  439.     if (LIST_NULL = g_listComponentSizes) then
  440.         nRetErr = nRetErr - 1;
  441.     endif;
  442.  
  443.     // Now cycle through the components calculating their sizes
  444.     nListResult = ListGetFirstString(g_listComponentDirectories, szDir);
  445.     while (END_OF_LIST != nListResult)
  446.         // Get size
  447.         nComponentSize = NGetComponentFileSize(szPegasusCPU, szDir);
  448.         // Add it to list of component sizes
  449.         nRetErr = nRetErr + ListAddItem (g_listComponentSizes, nComponentSize, AFTER);
  450.  
  451.         nListResult = ListGetNextString(g_listComponentDirectories, szDir);
  452.     endwhile;
  453.  
  454.     // Check for errors...
  455.     if ( nRetErr < 0 ) then
  456.         MessageBox ("Memory low. Unable to create string list.", SEVERE);
  457.         exit;                                // bail
  458.     endif;
  459. end;
  460.  
  461.  
  462. /*++
  463.  
  464.     InitializeComponentVars:
  465.     - initialize all variables for components
  466.     - create any dynamically-allocated lists, which will be destroyed in the "CleanUp" function
  467.  
  468.     Arguments:
  469.     None
  470.  
  471.     Return Value:
  472.     None
  473. --*/
  474. function InitializeComponentVars()
  475.     NUMBER  nRetErr;
  476.     NUMBER    i;
  477. begin
  478.     nRetErr = 0;        // no errors yet
  479.  
  480.     // We maintain a list of file extensions that should be decompressed from the games.z file to the desktop.
  481.     // This list does NOT contain the CPU type defined in szPegasusCPU.
  482.     g_listFileExtensions = ListCreate(STRINGLIST);
  483.     if (LIST_NULL = g_listFileExtensions) then
  484.         nRetErr = nRetErr - 1;
  485.     endif;
  486.     // Now populate this list...
  487.     nRetErr = nRetErr + ListAddString (g_listFileExtensions, "load", AFTER);        // needed for each component
  488.     //nRetErr = nRetErr + ListAddString (g_listFileExtensions, "unload", AFTER);        // needed for each component to make uninstall clean // BUGBUG: ido put this back!
  489.     nRetErr = nRetErr + ListAddString (g_listFileExtensions, "wav", AFTER);
  490.     nRetErr = nRetErr + ListAddString (g_listFileExtensions, "htc", AFTER);
  491.     nRetErr = nRetErr + ListAddString (g_listFileExtensions, "htp", AFTER);
  492.     nRetErr = nRetErr + ListAddString (g_listFileExtensions, "2bp", AFTER);
  493.     nRetErr = nRetErr + ListAddString (g_listFileExtensions, "txt", AFTER);
  494.     nRetErr = nRetErr + ListAddString (g_listFileExtensions, "dll", AFTER);
  495.     nRetErr = nRetErr + ListAddString (g_listFileExtensions, "ico", AFTER);
  496.     nRetErr = nRetErr + ListAddString (g_listFileExtensions, "exe", AFTER);
  497.     nRetErr = nRetErr + ListAddString (g_listFileExtensions, "doc", AFTER);
  498.     
  499.     // $ADDGAME - add more file extensions here
  500.  
  501.     // First, initialize the lists we need.  We'll populate them later.
  502.     g_listComponentNames = ListCreate(STRINGLIST);
  503.     if (LIST_NULL = g_listComponentNames) then
  504.         nRetErr = nRetErr - 1;
  505.     endif;
  506.     g_listComponentSizes = ListCreate(NUMBERLIST);
  507.     if (LIST_NULL = g_listComponentSizes) then
  508.         nRetErr = nRetErr - 1;
  509.     endif;
  510.     g_listComponentDirectories = ListCreate(STRINGLIST);
  511.     if (LIST_NULL = g_listComponentDirectories) then
  512.         nRetErr = nRetErr - 1;
  513.     endif;
  514.     g_listComponentsToInstall = ListCreate(NUMBERLIST);
  515.     if (LIST_NULL = g_listComponentsToInstall) then
  516.         nRetErr = nRetErr - 1;
  517.     endif;
  518.     g_listComponentPPCLoadFile = ListCreate(STRINGLIST);
  519.     if (LIST_NULL = g_listComponentPPCLoadFile) then
  520.         nRetErr = nRetErr - 1;
  521.     endif;
  522.     g_listComponentUninstallName = ListCreate(STRINGLIST);
  523.     if (LIST_NULL = g_listComponentUninstallName) then
  524.         nRetErr = nRetErr - 1;
  525.     endif;
  526.  
  527.     // These are the names that appear in the component-selection dialog box:
  528.     nRetErr = nRetErr + ListAddString (g_listComponentNames, "Paint Program for Windows CE", AFTER);
  529.     nRetErr = nRetErr + ListAddString (g_listComponentNames, "Cascading Menus", AFTER);
  530.     nRetErr = nRetErr + ListAddString (g_listComponentNames, "Control Panel Annunciators", AFTER);
  531.     nRetErr = nRetErr + ListAddString (g_listComponentNames, "Mute", AFTER);
  532.     nRetErr = nRetErr + ListAddString (g_listComponentNames, "Remote Control for Windows CE", AFTER);
  533.     nRetErr = nRetErr + ListAddString (g_listComponentNames, "Sound Scheme: Analog", AFTER);
  534.     nRetErr = nRetErr + ListAddString (g_listComponentNames, "Sound Scheme: Metallic", AFTER);
  535.     nRetErr = nRetErr + ListAddString (g_listComponentNames, "Sound Scheme: Organic", AFTER);
  536.     nRetErr = nRetErr + ListAddString (g_listComponentNames, "Bitmap Tiles", AFTER);
  537.     // $ADDGAME - add more names here
  538.  
  539.     // Here are the component sizes.  However, since we have not yet determined the CPU
  540.     // type of this machine, we can't do this calculation now.  Therefore, we fill
  541.     // the list now with bogus data so that it can be destroyed before the real list is
  542.     // created later.
  543.     for    i = 1 to ListCount(g_listComponentNames)
  544.         nRetErr = nRetErr + ListAddItem (g_listComponentSizes, 1, AFTER);
  545.     endfor;
  546.  
  547.     // These are the names of the directories in which each game has been compressed in the games.z file.
  548.     nRetErr = nRetErr + ListAddString (g_listComponentDirectories, "Ppaint", AFTER);
  549.     nRetErr = nRetErr + ListAddString (g_listComponentDirectories, "Cascade", AFTER);
  550.     nRetErr = nRetErr + ListAddString (g_listComponentDirectories, "Annun", AFTER);
  551.     nRetErr = nRetErr + ListAddString (g_listComponentDirectories, "Mute", AFTER);
  552.     nRetErr = nRetErr + ListAddString (g_listComponentDirectories, "Rcontrol", AFTER);
  553.     nRetErr = nRetErr + ListAddString (g_listComponentDirectories, "Sound1", AFTER);
  554.     nRetErr = nRetErr + ListAddString (g_listComponentDirectories, "Sound2", AFTER);
  555.     nRetErr = nRetErr + ListAddString (g_listComponentDirectories, "Sound3", AFTER);
  556.     nRetErr = nRetErr + ListAddString (g_listComponentDirectories, "Wall", AFTER);
  557.     // $ADDGAME - add more directory names here
  558.  
  559.     // This is a boolean list of which components to install.  The system maintains this automatically.
  560.     for    i = 1 to ListCount(g_listComponentNames)
  561.         nRetErr = nRetErr + ListAddItem (g_listComponentsToInstall, 1, AFTER);
  562.     endfor;
  563.  
  564.     // This is a list of the .load filenames to send to PPCLoad.DLL
  565.     nRetErr = nRetErr + ListAddString (g_listComponentPPCLoadFile, "Ppaint.load", AFTER);
  566.     nRetErr = nRetErr + ListAddString (g_listComponentPPCLoadFile, "Cascade.load", AFTER);
  567.     nRetErr = nRetErr + ListAddString (g_listComponentPPCLoadFile, "Annunciator.load", AFTER);
  568.     nRetErr = nRetErr + ListAddString (g_listComponentPPCLoadFile, "Mute.load", AFTER);
  569.     nRetErr = nRetErr + ListAddString (g_listComponentPPCLoadFile, "RemoteControl.load", AFTER);
  570.     nRetErr = nRetErr + ListAddString (g_listComponentPPCLoadFile, "Analog.load", AFTER);
  571.     nRetErr = nRetErr + ListAddString (g_listComponentPPCLoadFile, "Metallic.load", AFTER);
  572.     nRetErr = nRetErr + ListAddString (g_listComponentPPCLoadFile, "Organic.load", AFTER);
  573.     nRetErr = nRetErr + ListAddString (g_listComponentPPCLoadFile, "Wallpaper.load", AFTER);
  574.     // $ADDGAME - add more .load files here
  575.  
  576.     // This is a list of names users will see when they try to uninstall components
  577.     nRetErr = nRetErr + ListAddString (g_listComponentUninstallName, "Ppaint", AFTER);
  578.     nRetErr = nRetErr + ListAddString (g_listComponentUninstallName, "Cascade", AFTER);
  579.     nRetErr = nRetErr + ListAddString (g_listComponentUninstallName, "Annunciator", AFTER);
  580.     nRetErr = nRetErr + ListAddString (g_listComponentUninstallName, "Mute", AFTER);
  581.     nRetErr = nRetErr + ListAddString (g_listComponentUninstallName, "RemoteControl", AFTER);
  582.     nRetErr = nRetErr + ListAddString (g_listComponentUninstallName, "Analog", AFTER);
  583.     nRetErr = nRetErr + ListAddString (g_listComponentUninstallName, "Metallic", AFTER);
  584.     nRetErr = nRetErr + ListAddString (g_listComponentUninstallName, "Organic", AFTER);
  585.     nRetErr = nRetErr + ListAddString (g_listComponentUninstallName, "Wallpaper", AFTER);
  586.     // $ADDGAME - add more uninstall names here
  587.  
  588.     // Check for errors...
  589.     if ( nRetErr < 0 ) then
  590.         MessageBox ("Memory low. Unable to create string lists.", SEVERE);
  591.         exit;                                // bail
  592.     endif;
  593. end;
  594.  
  595.  
  596. /*++
  597.  
  598.     CleanUpComponentVars:
  599.     - destroy lists created for components
  600.  
  601.     Arguments:
  602.     None
  603.  
  604.     Return Value:
  605.     None
  606. --*/
  607. function CleanUpComponentVars()
  608. begin
  609.     // We need to destroy the file extensions list we created
  610.     ListDestroy(g_listFileExtensions);
  611.  
  612.     // We need to destroy the component lists we created
  613.     ListDestroy(g_listComponentNames);
  614.     ListDestroy(g_listComponentSizes);
  615.     ListDestroy(g_listComponentDirectories);
  616.     ListDestroy(g_listComponentsToInstall);
  617.     ListDestroy(g_listComponentPPCLoadFile);
  618.     ListDestroy(g_listComponentUninstallName);
  619. end;
  620.  
  621.  
  622.  
  623. /*++
  624.  
  625.     InitializeGlobals:
  626.     - initialize all variables global to all functions
  627.     - create any dynamically-allocated lists, which will be destroyed in the "CleanUp" function
  628.  
  629.     Arguments:
  630.     None
  631.  
  632.     Return Value:
  633.     None
  634. --*/
  635. function InitializeVariables()
  636.     STRING  szMinervaLocation;
  637.     STRING  szTemp;
  638.     NUMBER  nvRegType;
  639.     NUMBER  nvSize;
  640.     STRING  szInstDir;
  641. begin
  642.     g_szDllFilename = SUPPORTDIR ^ SZ_PEGLOAD_DLL; // BUGBUG: Note we are using a local version of this!
  643.     g_szDllFilename1 = SUPPORTDIR ^ szPRIVATE_HELPER_DLL; // BUGBUG: Note we are using a local version of this!
  644.  
  645.     if ( UseDLL( g_szDllFilename ) < 0 ) then
  646.     MessageBox( "Cannot load or find PPCLOAD.DLL, which is required for installation.\nPlease ensure PPCLOAD.DLL is available in the current path.", SEVERE );
  647.     exit;
  648.     endif;
  649.  
  650.     // load our private helper DLL
  651.     if ( UseDLL( g_szDllFilename1 ) < 0 ) then
  652.         MessageBox( "Cannot load or find DELVAL.DLL, which is required for installation.\nPlease ensure DELVAL.DLL is available in the current path.", SEVERE );
  653.         exit;
  654.     endif;
  655.  
  656.     nTotalFileSize = 0;
  657.  
  658.     // get the InstallShield-system variables
  659.     if ( !FGetDesktopDirectory( g_hwnd, szFOLDER_DESKTOP ) ) then
  660.         szFOLDER_DESKTOP = WINDIR ^ "desktop";    // set the error case to our best guess
  661.     endif;
  662.     if ( !FGetStartupDirectory( g_hwnd, szFOLDER_STARTUP ) ) then
  663.         szFOLDER_STARTUP = WINDIR ^ "start menu\\programs\\startup";  // set the error case to our best guess
  664.     endif;
  665.  
  666.  
  667.  
  668.     // set the default destination directories
  669.     // For the desktop location we first have to figure out if the HPC Explorer has been installed yet, since
  670.     // we want to use its install path.
  671.     RegDBSetDefaultRoot( HKEY_LOCAL_MACHINE );
  672.     if ( 0 > RegDBGetKeyValueEx("\\SOFTWARE\\Microsoft\\Pegasus", "InstalledDir", nvRegType, szMinervaLocation, nvSize)) then
  673.         // Hasn't been installed yet, so we can't run setup.
  674.         MessageBox( "Setup cannot find a version of HPC Explorer on this computer.\n\n" +
  675.                     "Please make sure HPC Explorer is installed and then run Setup again.", SEVERE );
  676.         CleanUp();
  677.     else
  678.         // Check to see if the registry value is legal. If it isn't, use a default.
  679.         if ( ( GetDisk( szMinervaLocation, szTemp ) = 0 ) && ( "" != szTemp ) ) then
  680.             szDestDirDesktop = szMinervaLocation ^ SZ_INSTALL_SUBDIR;
  681.         else 
  682.             szDestDirDesktop = TARGETDISK ^ SZ_DEFAULT_DESKTOP_LOCATION;
  683.         endif;
  684.     endif;
  685.  
  686.     szDestDirPegasus = SZ_DEST_DIR_PEGASUS;
  687.  
  688.     // get the user name and company
  689.     RegDBSetDefaultRoot( HKEY_CURRENT_USER );
  690.     if ( 0 > RegDBGetKeyValueEx("\\SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", "DefName", nvRegType, szUserName, nvSize) ) then
  691.     szUserName = "";
  692.     endif;
  693.     if ( 0 > RegDBGetKeyValueEx("\\SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", "DefCompany", nvRegType, szUserCompany, nvSize) ) then
  694.     szUserCompany = "";
  695.     endif;
  696.  
  697.     szUninstLogFile = "";
  698.  
  699.     // initialize the file set
  700.     szFileSet = "General";
  701.  
  702.     // initialize the Pegasus CPU
  703.     szPegasusCPU = "";
  704. end;
  705.  
  706.  
  707. /*++
  708.  
  709.     StripDoubleQuotes:
  710.     - to strip out all double-quotes from a string
  711.  
  712.     Arguments:
  713.     szText  - IN/OUT - text string to be stripped of double quotes
  714.  
  715.     Return Value:
  716.     None
  717.  
  718.     Notes:
  719.     We need to strip out double-quotes, because we use double-quotes to delimit strings passed
  720.     to PPCLoad::Load().  If we don't do this, PPCLoad::Load() will not read the parameters
  721.     correctly, and will report an error
  722. --*/
  723. function StripDoubleQuotes( szText )
  724.     NUMBER  nPos;
  725.     STRING  szTemp1, szTemp2;
  726. begin
  727.     nPos = StrFind( szText, "\"" );
  728.     while ( nPos >= 0 )
  729.     StrSub( szTemp1, szText, 0, nPos );
  730.     StrSub( szTemp2, szText, nPos + 1, StrLength( szText ) - nPos - 1 );
  731.     szText = szTemp1 + szTemp2;
  732.     nPos = StrFind( szText, "\"" );
  733.     endwhile;
  734. end;
  735.  
  736.  
  737. /*++
  738.  
  739.     SetupScreen:
  740.     - draw the background screen
  741.     - draw the main splash bitmap
  742.  
  743.     Arguments:
  744.     None
  745.  
  746.     Return Value:
  747.     None
  748. --*/
  749. function SetupScreen()
  750. begin
  751.     // set the title of all 'yes/no' dialogs
  752.     SetDialogTitle( DLG_ASK_YESNO, SZ_PRODUCT_NAME);
  753.         SetDialogTitle( DLG_MSG_INFORMATION, SZ_PRODUCT_NAME);
  754.         SetDialogTitle( DLG_MSG_WARNING, SZ_PRODUCT_NAME);
  755.         SetDialogTitle( DLG_MSG_SEVERE, SZ_PRODUCT_NAME);
  756.     
  757.     // disable the main background window
  758.     Disable( BACKGROUND );
  759.     // set the installation info, which is required for registry entries
  760.     InstallationInfo( SZ_COMPANY_NAME, SZ_PRODUCT_NAME, SZ_PRODUCT_VERSION, SZ_PRODUCT_KEY_1 );
  761.     
  762.     // start up full screen
  763.     Enable( FULLWINDOWMODE );
  764.     // use individuall filename resolution on progress indicator
  765.     Enable( INDVFILESTATUS );
  766.     // use 256 color bitmap
  767.     Enable( BITMAP256COLORS );
  768.  
  769.     // use the standard blue background
  770.     SetColor( BACKGROUND, BK_BLUE );    // gradient blue background
  771.  
  772.     // set the caption
  773.     SetTitle( SZ_PRODUCT_NAME, 0, BACKGROUNDCAPTION ); // caption bar text
  774.         SetTitle( SZ_PRODUCT_NAME, 28, WHITE ); // caption bar text
  775.  
  776.     // get the background window
  777.     g_hwnd = GetActiveWindow();
  778.  
  779.     // maximize the window
  780.     ShowWindow( g_hwnd, SW_MAXIMIZE );
  781.  
  782.     // re-enable the background window
  783.     Enable( BACKGROUND );
  784.  
  785.     // enable the dialog cache to eliminate screen flashing between dialogs
  786.     Enable( DIALOGCACHE );
  787.  
  788.     // set the bitmap for each dialog box
  789.     DialogSetInfo( DLG_INFO_ALTIMAGE, "@" + SUPPORTDIR ^ SZ_BITMAP_DIALOG, TRUE );  // IShield docs says "@" is necessary
  790. end;
  791.  
  792.  
  793. /*++
  794.  
  795.     SetupWelcome:
  796.     - display the welcome dialog
  797.  
  798.     Arguments:
  799.     None
  800.  
  801.     Return Value:
  802.     None
  803. --*/
  804. function SetupWelcome()
  805. begin
  806.     // disable back button dialog
  807.     Disable( BACKBUTTON );
  808.     // set product name in welcome dialog
  809.     SdProductName( SZ_PRODUCT_NAME );
  810.     // show welcome dialog
  811.     SdWelcome( SZ_PRODUCT_NAME, "Welcome to %P Setup. Setup will copy the PowerToys to your desktop computer first, and then install it on your HPC." ); // $MODIFY
  812.     // re-enable the back button in the welcome dialog
  813.     Enable( BACKBUTTON );
  814. end;
  815.  
  816.  
  817. /*++
  818.  
  819.     DoSystemTest:
  820.     - determine if Minerva has been installed
  821.     - check for minimum hard drive space
  822.     - determine the operating system (for operating system-specific functionality)
  823.  
  824.     Arguments:
  825.     OUT:    szPegasusCPU    - the Pegasus CPU type
  826.  
  827.     Return Value:
  828.     None
  829. --*/
  830. function DoSystemTest( szPegasusCPU )
  831.     POINTER psz;
  832. begin
  833.     // we want to pass 'szPegasusCPU' by reference - this is how it's done in InstallShield
  834.     psz = AddressString( szPegasusCPU );
  835.  
  836.     // get the CPU type from PegLoad
  837.     if ( !Load_PegCpuType( psz ) ) then
  838.     // CPU not supported
  839.     MessageBox( "Setup does not recognize the HPC CPU type, or the HPC Explorer has not been run yet.\n\n" +
  840.                     "Please refer to the documentation for more details.", SEVERE );
  841.     CleanUp();
  842.     endif;
  843.  
  844.     // at this point, 'szPegasusCPU' will have the correct string
  845. end;
  846.  
  847.  
  848. /*++
  849.  
  850.     CheckForConflicts:
  851.     - determine if a copy of this setup is running
  852.     - determine if PegMan is currently running
  853.     - check for any other active programs that might conflict with setup
  854.  
  855.     Arguments:
  856.     None
  857.  
  858.     Return Value:
  859.     None
  860. --*/
  861. function CheckForConflicts()
  862.     HWND    hwnd, hwndNext;
  863.     STRING  szConflicts;
  864.     STRING  szWarning;
  865. begin
  866.     szConflicts = "";
  867.  
  868.     // first, get the active window
  869.     hwnd = GetActiveWindow();
  870.     // now check if another instance of this Setup is running
  871.     hwndNext = FindWindowEx( 0, hwnd, "InstallShield_Win", 0 );
  872.     if ( hwndNext && (hwndNext != hwnd) ) then
  873.     // there are problems when closing this window and restoring the other one - so we will just warn the user
  874.     szConflicts = szConflicts + "\nInstallShield Setup";
  875.     endif;
  876.  
  877.     // check if Minerva is currently running
  878.     /* We don't have to do this. commented out to fix bug 13657
  879.     hwnd = FindWindowEx( 0, 0, "PegMgrClass", 0 );
  880.     if ( hwnd ) then
  881.     szConflicts = szConflicts + "\n" + SZ_COMPANY_NAME + " " + SZ_MINERVA_NAME;
  882.     endif;
  883.     */
  884.  
  885.     // BUGBUG - now check for other programs here
  886.  
  887.     // print out an error message if conflicts are encountered
  888.     if ( szConflicts != "" ) then
  889.     szWarning = SZ_PRODUCT_NAME + " Setup has determined that the following application(s) are running:\n" +
  890.             szConflicts + "\n\nWe recommend that you close these application(s) before continuing. " +
  891.             "Continue with setup?";
  892.     if ( NO = AskYesNo( szWarning, NO ) ) then
  893.         CleanUp();
  894.     endif;
  895.     endif;
  896. end;
  897.  
  898.  
  899.  
  900. /*++
  901.  
  902.     NGetComponentFileSize:
  903.     - calculates the size of a component given the directory in the compressed file that contains
  904.       that component.
  905.  
  906.     Arguments:
  907.     IN:     szPegasusCPU         - the Pegasus CPU type
  908.     IN:     szComponentDirectory - dir in the compressed file containing the component
  909.  
  910.     Return Value:
  911.     The total file size of the component
  912. --*/
  913. function NGetComponentFileSize( szPegasusCPU, szComponentDirectory )
  914.     NUMBER nvSize;            // file size
  915.     STRING svInfo;
  916.     NUMBER nComponentSize;    // total component size
  917.     STRING szFileExtension;
  918.     NUMBER nListResult;        // used to traverse a list
  919. begin
  920.     // Initialize component size
  921.     nComponentSize = 0;
  922.  
  923.     // We calculate the component size by adding the following:
  924.     //   1) The CPU-specific files (exe's and dll's)
  925.     //   2) The files ending in extensions specified in g_listFileExtensions
  926.  
  927.     // Get CPU specific size
  928.     CompressInfo( SZ_SOURCE_FILE, szComponentDirectory + "\\*." + szPegasusCPU, COMP_INFO_ORIGSIZE | INCLUDE_SUBDIR, nvSize, svInfo );
  929.     nComponentSize = nComponentSize + nvSize;
  930.  
  931.     // Now get the file sizes of the files specified in g_listFileExtensions
  932.     nListResult = ListGetFirstString (g_listFileExtensions, szFileExtension);
  933.     while (END_OF_LIST != nListResult)
  934.         CompressInfo( SZ_SOURCE_FILE, szComponentDirectory + "\\*." + szFileExtension, COMP_INFO_ORIGSIZE | INCLUDE_SUBDIR, nvSize, svInfo );
  935.         nComponentSize = nComponentSize + nvSize;
  936.         nListResult = ListGetNextString (g_listFileExtensions, szFileExtension);
  937.     endwhile;
  938.  
  939.     return nComponentSize;
  940. end;
  941.  
  942.  
  943. /*++
  944.  
  945.     NGetTotalFileSize:
  946.     - calculate the total file size of all the components that the user has selected to install.
  947.  
  948.     Arguments:
  949.     IN:     szPegasusCPU    - the Pegasus CPU type
  950.  
  951.     Return Value:
  952.     The total file size
  953. --*/
  954. function NGetTotalFileSize( szPegasusCPU )
  955.     NUMBER    nTotalSize;
  956.     NUMBER    nInstallComponent, nComponentSize;
  957.     NUMBER    nListResult;                // used to traverse a list
  958. begin
  959.     nTotalSize = 0;
  960.     
  961.     // Cycle through all the components to see which is installed and get their sizes.
  962.     nListResult = ListGetFirstItem (g_listComponentsToInstall, nInstallComponent);
  963.     ListGetFirstItem (g_listComponentSizes, nComponentSize);
  964.     while (END_OF_LIST != nListResult)
  965.         if (nInstallComponent) then        // are we installing this component?
  966.             nTotalSize = nTotalSize + nComponentSize;
  967.         endif;
  968.         nListResult = ListGetNextItem (g_listComponentsToInstall, nInstallComponent);
  969.         ListGetNextItem (g_listComponentSizes, nComponentSize);
  970.     endwhile;
  971.  
  972.     return nTotalSize;
  973. end;
  974.  
  975.  
  976. /*++
  977.  
  978.     NRegisterUser:
  979.     - get and save the user and company name
  980.  
  981.     Arguments:
  982.     OUT:    szUserName      - the user's name
  983.     OUT:    szUserCompany   - the user's company
  984.     Return Value:
  985.     BACK    - go back to last dialog
  986.     NEXT    - continue to next dialog
  987. --*/
  988. function NRegisterUser( szUserName, szUserCompany )
  989.     STRING  szMsg;
  990.     NUMBER  nResult;
  991.     BOOL    fNameEntered;
  992. begin
  993.     // InstallShield's "SdRegisterUser" dialog will disable the NEXT button unless both
  994.     // fields are non-empty.  Instead, we will allow for blanks
  995.     szMsg = "Enter your name and company information below.";
  996.     fNameEntered = FALSE;
  997.     while ( !fNameEntered )
  998.         nResult = SdShowDlgEdit2( SZ_PRODUCT_NAME, szMsg, "N&ame:", "&Company:", szUserName, szUserCompany );
  999.     if ( (BACK = nResult) || (szUserName != "") ) then
  1000.         // exit the loop
  1001.         fNameEntered = TRUE;
  1002.     else
  1003.         MessageBox( "You must enter a name to continue.", WARNING );
  1004.     endif;
  1005.     endwhile;
  1006.     
  1007.     // bugbug - do something with the user name/company
  1008.     return nResult;
  1009. end;
  1010.  
  1011.  
  1012. /*++
  1013.  
  1014.     NGetDestDesktop:
  1015.     - ask for the destination directory on the desktop
  1016.     - create the directory if it does not exist
  1017.  
  1018.     Arguments:
  1019.     OUT:    szDestDirDesktop   - the destination directory on the desktop
  1020.  
  1021.     Return Value:
  1022.     BACK    - go back to last dialog
  1023.     NEXT    - continue to next dialog
  1024. --*/
  1025. function NGetDestDesktop( szDestDirDesktop )
  1026.     BOOL    fValidPath;     // is the destination directory a valid path?
  1027.     NUMBER  nRetErr;
  1028. begin
  1029.     fValidPath = FALSE;
  1030.     while ( !fValidPath )
  1031.     nRetErr = AskDestPath( "Select Destination Directory on the Desktop",
  1032.                    "Setup will install " + SZ_PRODUCT_NAME + " in the following destination directory " +
  1033.                    "on the Desktop.\n\n" +
  1034.                    "To install to this directory, click Next.\n\n" +
  1035.                    "To install to a different directory, click the Browse button.",
  1036.                    szDestDirDesktop, 0 );
  1037.     
  1038.     if ( nRetErr < 0 ) then
  1039.         MessageBox( "Directory creation error.  Please check your target location and try again.", SEVERE );
  1040.         CleanUp();
  1041.  
  1042.     elseif ( nRetErr = BACK ) then
  1043.         // fake a valid path to exit the loop
  1044.         fValidPath = TRUE;
  1045.  
  1046.     elseif ( nRetErr = NEXT ) then
  1047.         // check for valid path - the above dialog does not always check, it seems
  1048.         if ( ExistsDir( szDestDirDesktop ) = NOTEXISTS ) then
  1049.         if ( YES = AskYesNo( "The directory:\n\n'" + szDestDirDesktop +
  1050.                      "'\n\ndoes not exist.  Do you want the directory to be created?", YES ) )
  1051.         then
  1052.             // create the new directory
  1053.             if ( CreateDir( szDestDirDesktop ) < 0 ) then
  1054.             MessageBox( "Cannot create directory:\n\n'" + szDestDirDesktop + "'\n\nPlease select a different directory.", WARNING );
  1055.             else
  1056.             fValidPath = TRUE;
  1057.             endif;
  1058.         endif;
  1059.         else
  1060.         fValidPath = TRUE;
  1061.         endif;
  1062.     endif;
  1063.     endwhile;
  1064.  
  1065.     return nRetErr;
  1066. end;
  1067.  
  1068.  
  1069. /*++
  1070.  
  1071.     FCheckEnoughSpace:
  1072.     - check if there is enough hard drive space for the selected components
  1073.     - calls 'NGetSelectionSize' to determine the total file size of the selected components
  1074.  
  1075.     Arguments:
  1076.     IN:     nTotalFileSize      - total file size
  1077.     IN:     szDestDirDesktop    - destination directory on desktop
  1078.  
  1079.     Return Value:
  1080.     TRUE    - enough space
  1081.     FALSE   - not enough space
  1082. --*/
  1083. function FCheckEnoughSpace( nTotalFileSize, szDestDirDesktop )
  1084.     NUMBER  nTotalWithExtra;    // total size with extra space required
  1085.     NUMBER  nDiskSpace;         // total remaining disk space
  1086.     STRING  szMsg;
  1087. begin
  1088.     nTotalWithExtra = nTotalFileSize + cEXTRA_SPACE_REQUIRED;
  1089.  
  1090.     // check if target disk has enough space
  1091.     nDiskSpace = GetDiskSpace( szDestDirDesktop );
  1092.     if ( nDiskSpace < nTotalWithExtra ) then
  1093.     Sprintf( szMsg, "There is not enough disk space available to install the\n" + SZ_PRODUCT_NAME + "installation files in the following location:\n\n" +
  1094.             "'" + szDestDirDesktop + "'\n\nSetup requires at least %ld bytes free. Continue anyway?", nTotalWithExtra );
  1095.     if ( NO = AskYesNo( szMsg, NO ) ) then
  1096.         return FALSE;
  1097.     endif;
  1098.     endif;
  1099.     return TRUE;    // enough space, or user want to continue anyways
  1100. end;
  1101.  
  1102.  
  1103. /*++
  1104.  
  1105.     NGetDestPegasus:
  1106.     - ask for the destination directory on the Pegasus
  1107.  
  1108.     Arguments:
  1109.     OUT:    szDestDirPegasus    - the destination directory on the Pegasus
  1110.  
  1111.     Return Value:
  1112.     BACK    - go back to last dialog
  1113.     NEXT    - continue to next dialog
  1114.  
  1115.     NOTE:
  1116.     We cannot determine if the path is valid on the Pegasus.  The path will be created when PPCLOAD.DLL is
  1117.     called, and it will fail if it cannot create the directory, or there is not enough space on the Pegasus.
  1118. --*/
  1119. function NGetDestPegasus( szDestDirPegasus )
  1120.     NUMBER  nRetErr;
  1121.     STRING  szTempDir;
  1122. begin
  1123.     // set the dialog title
  1124.     SetDialogTitle( DLG_ASK_TEXT, "Select Destination Directory on the HPC.");
  1125.  
  1126.     szTempDir = szDestDirPegasus;
  1127.     // ask for the destination directory on the Pegasus
  1128.     nRetErr = AskText( "Setup will install " + SZ_PRODUCT_NAME + " in the following destination directory " +
  1129.                "on the HPC." +
  1130.                "To install to this directory, click Next.",
  1131.                szTempDir, szDestDirPegasus );
  1132.  
  1133.     if ( NEXT = nRetErr ) then
  1134.     // strip the drive letter if it was included
  1135.     GetDir( szDestDirPegasus, szDestDirPegasus );
  1136.  
  1137.     // PPCLOAD.DLL requires that the path be absolute - since there is no such thing as relative paths on the Pegasus
  1138.     // So, instead of elaborate checks to ensure an initial backslash ("\") at the beginning of the path,
  1139.     // we will use InstallShield's built-in functions...
  1140.     szTempDir = "C:" ^ szDestDirPegasus;    // create a dummy drive letter
  1141.     GetDir( szTempDir, szDestDirPegasus );  // get the pathname, which will include the initial backslash
  1142.  
  1143.     // strip out double-quotes
  1144.     StripDoubleQuotes( szDestDirPegasus );
  1145.     else
  1146.     // the BACK button was pressed
  1147.     szDestDirPegasus = szTempDir;
  1148.     endif;
  1149.     return nRetErr;
  1150. end;
  1151.  
  1152.  
  1153. /*++
  1154.  
  1155.     NGetCopyConfirmation:
  1156.     - display the components selected, the destination directory, and the destination folder
  1157.     - ask for user confirmation
  1158.  
  1159.     Arguments:
  1160.     IN:     nTotalFileSize      - total file size
  1161.     IN:     szDestDirDesktop    - destination directory on desktop
  1162.     IN:     szDestDirPegasus    - destination directory on Pegasus
  1163.  
  1164.     Return Value:
  1165.     BACK    - go to previous dialog
  1166.     NEXT    - go to next dialog
  1167. --*/
  1168. function NGetCopyConfirmation( nTotalFileSize, szDestDirDesktop, szDestDirPegasus)
  1169.     LIST    listInfo;   // list to contain the displayed info
  1170.     NUMBER  nRetErr;
  1171.     STRING  szFileSize;
  1172. begin
  1173.     nRetErr = 0;        // all list errors are less than zero
  1174.  
  1175.     listInfo = ListCreate( STRINGLIST );
  1176.     if ( listInfo = LIST_NULL ) then
  1177.     // forget the confirmation if there was an error
  1178.     return NEXT;
  1179.     endif;
  1180.  
  1181.     // show total size
  1182.     NumToStr( szFileSize, nTotalFileSize );
  1183.     nRetErr = nRetErr + ListAddString( listInfo, "Total File Size:", AFTER );
  1184.     nRetErr = nRetErr + ListAddString( listInfo, "\t" + szFileSize + " bytes", AFTER );
  1185.  
  1186.     // show destination directory on desktop
  1187.     nRetErr = nRetErr + ListAddString( listInfo, "", AFTER );
  1188.     nRetErr = nRetErr + ListAddString( listInfo, "Desktop Destination Directory:", AFTER );
  1189.     nRetErr = nRetErr + ListAddString( listInfo, "\t" + szDestDirDesktop, AFTER );
  1190.  
  1191.     // show destination directory on Pegasus
  1192.     nRetErr = nRetErr + ListAddString( listInfo, "", AFTER );
  1193.     nRetErr = nRetErr + ListAddString( listInfo, "Pegasus Destination Directory:", AFTER );
  1194.     nRetErr = nRetErr + ListAddString( listInfo, "\t" + szDestDirPegasus, AFTER );
  1195.  
  1196.     // bypass copy confirmation if there were any errors
  1197.     if ( nRetErr < 0 ) then
  1198.     ListDestroy( listInfo );
  1199.     return NEXT;
  1200.  
  1201.     else
  1202.     // show copy confirmation dialog
  1203.     nRetErr = SdStartCopy( "Start Copying Files", "Setup is ready to start copying files. If you want " +
  1204.                    "to change any settings, click Back.  If you are satisfied with the settings, " +
  1205.                    "click Next to begin copying files.", listInfo );
  1206.     ListDestroy( listInfo );
  1207.     endif;
  1208.     return nRetErr;
  1209. end;
  1210.  
  1211.  
  1212. /*++
  1213.  
  1214.     CreateUninstallInfo:
  1215.     - create the uninstallation information for the desktop required by InstallShield3
  1216.  
  1217.     Arguments:
  1218.     OUT:    szUninstLogFile     - log file to store uninstall info
  1219.     IN:     szDestDirDesktop    - destination directory on desktop
  1220.  
  1221.     Return Value:
  1222.     None
  1223. --*/
  1224. function CreateUninstallInfo( szUninstLogFile, szDestDirDesktop )
  1225. begin
  1226.     DeinstallStart( szDestDirDesktop, szUninstLogFile, SZ_DEINSTALL_KEY, 0 );
  1227.     RegDBSetItem( REGDB_UNINSTALL_NAME, SZ_UNINSTALL_NAME );
  1228. end;
  1229.  
  1230.  
  1231. /*++
  1232.  
  1233.     SetupFileTransfer:
  1234.     - create the "File Set", to prepare a log of which files that need to be uncompressed and copied
  1235.  
  1236.     Arguments:
  1237.     OUT:    szFileSet           - the "File Set", a log of files to be copied
  1238.     IN:     szDestDirDesktop    - destination directory on the desktop
  1239.     IN:     szPegasusCPU        - Pegasus CPU type
  1240.  
  1241.     Return Value:
  1242.     None
  1243. --*/
  1244. function SetupFileTransfer( szFileSet, szDestDirDesktop, szPegasusCPU )
  1245.     NUMBER    nvSize;            // file size
  1246.     STRING    svInfo;
  1247.     NUMBER  nRetErr;        // all error codes are less than zero
  1248.     NUMBER    nExist;            // checks to see if file extensions used for particular component
  1249.     NUMBER    nListResult;    // used to traverse a list
  1250.     STRING    szComponentDir;
  1251.     NUMBER    nInstall;
  1252.     STRING    szFileExtension;
  1253. begin
  1254.     // set the default target
  1255.     TARGETDIR = szDestDirDesktop;
  1256.  
  1257.     // define the file set to be copied to the user's machine
  1258.     FileSetBeginDefine( szFileSet );
  1259.     // copy over all the files for the Pegasus CPU type
  1260.     SetStatusWindow( -1, "Copying files to the desktop PC..." );
  1261.     nRetErr = 0;
  1262.  
  1263.     // copy file to desktop for each component
  1264.     nListResult = ListGetFirstString(g_listComponentDirectories, szComponentDir);
  1265.     nListResult = ListGetFirstItem(g_listComponentsToInstall, nInstall);
  1266.     while (END_OF_LIST != nListResult)
  1267.         if (nInstall) then
  1268.  
  1269.             // Set the target directory on the desktop (different for each component)
  1270.             TARGETDIR = szDestDirDesktop ^ szComponentDir;
  1271.  
  1272.             // Get CPU-specific files first
  1273.             nRetErr = nRetErr + CompressGet( SZ_SOURCE_FILE, szComponentDir + "\\*." + szPegasusCPU,
  1274.                                              COMP_NORMAL | INCLUDE_SUBDIR );
  1275.  
  1276.             // Now let's get the non-CPU-specific files
  1277.             nListResult = ListGetFirstString (g_listFileExtensions, szFileExtension);
  1278.             while (END_OF_LIST != nListResult)
  1279.                 // See if there are any files of this type to get for the component!!
  1280.                 nExist = CompressInfo( SZ_SOURCE_FILE, szComponentDir + "\\" + "*." + szFileExtension,
  1281.                          COMP_INFO_ORIGSIZE | INCLUDE_SUBDIR, nvSize, svInfo );
  1282.                 if (0 = nExist) then
  1283.                     nRetErr = nRetErr + CompressGet( SZ_SOURCE_FILE, szComponentDir + "\\*." +
  1284.                                         szFileExtension, COMP_NORMAL | INCLUDE_SUBDIR );
  1285.                 endif;
  1286.                 nListResult = ListGetNextString (g_listFileExtensions, szFileExtension);
  1287.             endwhile;
  1288.         endif;
  1289.         nListResult = ListGetNextString(g_listComponentDirectories, szComponentDir);
  1290.         nListResult = ListGetNextItem(g_listComponentsToInstall, nInstall);
  1291.     endwhile;
  1292.  
  1293.     if ( nRetErr < 0 ) then
  1294.         MessageBox( "Error copying files.", WARNING );
  1295.     endif;
  1296.     FileSetEndDefine( szFileSet );
  1297. end;
  1298.  
  1299.  
  1300. /*++
  1301.  
  1302.     DoFileTransfer:
  1303.     - perform the actual file copying, using the previously created "File Set"
  1304.  
  1305.     Arguments:
  1306.     IN:     szFileSet   - the "File Set", a log of files to be copied
  1307.  
  1308.     Return Value:
  1309.     None
  1310. --*/
  1311. function DoFileTransfer( szFileSet )
  1312.     NUMBER  nRetErr;
  1313.     STRING  szError;
  1314. begin
  1315.     // set up progress indicator and information gauge.
  1316.     Enable( STATUS );
  1317.     Disable( DIALOGCACHE );
  1318.     StatusUpdate( ON, 100 );
  1319.  
  1320.     // Perform the file set transfer
  1321.     nRetErr = FileSetPerformEz( szFileSet, 0 );
  1322.  
  1323.     switch ( nRetErr )
  1324.     case FS_DONE:
  1325.         // the transfer was completed successfully
  1326.  
  1327.         case FS_OUTOFSPACE:
  1328.         // out of disk space
  1329.         MessageBox("Setup ran out of disk space on " + TARGETDIR + " while copying files.\n\n" +
  1330.                        "Please free some space on the target location and run setup again.", SEVERE);
  1331.         CleanUp();
  1332.  
  1333.  
  1334.     case FS_CREATEDIR:  // create directory error
  1335.         MessageBox( "Unable to create a directory under\n\n'" + TARGETDIR + "'\n\n" +
  1336.             "Please check write access to this directory.", SEVERE );
  1337.         CleanUp();
  1338.  
  1339.     default:            // group all other errors under default label
  1340.         NumToStr( szError, nRetErr );
  1341.         MessageBox( "General file transfer error.  " +
  1342.             "Please check your target location and try again.\n\n"+
  1343.             "Error Number:  " + szError, SEVERE );
  1344.         CleanUp();
  1345.     endswitch;
  1346.     Disable( STATUS );
  1347. end;
  1348.  
  1349.  
  1350. /*++
  1351.  
  1352.     FinishSetup:
  1353.     - to display the finished-setup dialog
  1354.     - ask the user to view the 'readme' file
  1355.  
  1356.     Arguments:
  1357.     IN:     nTotalFileSize      - total file size
  1358.     IN:     szDestDirDesktop    - destination directory on desktop
  1359.     IN:     szDestDirPegasus    - destination directory on Pegasus
  1360.     IN:     szPegasusCPU        - Pegasus CPU type
  1361.     IN:     szUserName          - register user's name
  1362.     IN:     szUserCompany       - register user's company
  1363.  
  1364.     Return Value:
  1365.     None
  1366. --*/
  1367. function FinishSetup( nTotalFileSize, szDestDirDesktop, szDestDirPegasus, szPegasusCPU, szUserName, szUserCompany )
  1368.     STRING  szMsg1;
  1369.     STRING  szMsg2;
  1370.     STRING  szReadmeMsg;
  1371.     BOOL    fTemp;
  1372.     BOOL    fTemp2;
  1373.     NUMBER  nFileHandle;
  1374.  
  1375.     NUMBER  nRetErr;
  1376.     STRING  szErrCode;
  1377.     BOOL    fRetryDownload;
  1378.     HWND    hwndMine;       // window handle to this app
  1379.     STRING  szDllFilename;  // PPCLOAD.DLL filename - to load the program onto Pegasus
  1380.     
  1381.     STRING  szCmdLine;
  1382.     NUMBER  nPegFreeSpace;
  1383.  
  1384.     STRING  szAppName, szComponentDir, szLoadFile, szUninstall
  1385.     NUMBER  nComponentSize, nInstall;
  1386.     NUMBER  nListResult, nInstallResult;
  1387.  
  1388.     STRING    szReadmeFile;
  1389.     STRING    szTemp;
  1390.     STRING    szPathname;
  1391.     STRING    szFolderDir;
  1392.     
  1393. begin
  1394.     // So far no errors...
  1395.     nInstallResult = 1;
  1396.  
  1397.     // strip all double quotes for strings (we already do this for szDestDirPegasus)
  1398.     StripDoubleQuotes( szPegasusCPU );
  1399.     StripDoubleQuotes( szUserName );
  1400.     StripDoubleQuotes( szUserCompany );
  1401.  
  1402.     // get the current window handle
  1403.     // this must be done before launching the readme file, because it won't find our window handler!
  1404.     hwndMine = GetActiveWindow();
  1405.  
  1406.      szMsg1 = SZ_PRODUCT_NAME + " Setup has finished uncompressing the installation files to your desktop computer. " +
  1407.          "The program files will now be copied to your HPC.\n\nPlease ensure that your " +
  1408.          "HPC is connected and turned on.";
  1409.      szMsg2 = "Click Finish to start downloading to the HPC.";
  1410.     
  1411.     // show the finish dialog
  1412.     MessageBeep (0);
  1413.     SdFinish( "HPC Downloading", szMsg1, szMsg2, "", "", fTemp, fTemp2 );
  1414.  
  1415.     SdShowMsg("Starting download to the HPC. Please make sure the HPC is connected.", TRUE );
  1416.      // initialize PPCLOAD.DLL
  1417.     nRetErr = Load_Init();
  1418.     if ( nRetErr != 0 ) then
  1419.     MessageBox( "Setup could not start communications with the HPC.\n\nPlease check all connections and press OK to try again.", WARNING );
  1420.  
  1421.     // try a second time
  1422.     nRetErr = Load_Init();
  1423.     if ( nRetErr != 0 ) then
  1424.         MessageBox( "Setup could not start communications with the HPC.\n\nPlease reboot the HPC and try installing again.", SEVERE );
  1425.         CleanUp();
  1426.     endif;
  1427.     endif;
  1428.     SdShowMsg("", FALSE);
  1429.  
  1430.     // check if enough space
  1431.     nPegFreeSpace = Load_PegFreeSpace();
  1432.     //    SprintfBox( WARNING, "Free Space", "Required: %d   Free on Pegasus: %d", nTotalFileSize, nPegFreeSpace );
  1433.     if ( nPegFreeSpace < nTotalFileSize ) then    // add some extra space
  1434.     szMsg1 = "There is not enough free storage memory on the HPC to install\n" + SZ_PRODUCT_NAME + ".\n\n" +
  1435.                  "Please delete some files from the HPC or increase the\namount of storage memory available.\n\n" +
  1436.                  "Continue installation? (not recommended)";
  1437.     if ( NO = AskYesNo( szMsg1, NO ) ) then
  1438.         Load_Exit();
  1439.         MessageBox( "Download stopped. Please increase the amount of storage memory\n" + 
  1440.              "available on the HPC and run Setup again.", INFORMATION );
  1441.         CleanUp();
  1442.     endif;
  1443.     endif;
  1444.  
  1445.     // Hey, let's grab the first file to install
  1446.     nListResult = ListGetFirstString (g_listComponentNames, szAppName);
  1447.     nListResult = ListGetFirstString (g_listComponentPPCLoadFile, szLoadFile);
  1448.     nListResult = ListGetFirstString (g_listComponentUninstallName, szUninstall);
  1449.     nListResult = ListGetFirstItem (g_listComponentsToInstall, nInstall);
  1450.     // 8/30/96 idobs: Bugfix.  Should pass component size to pccload, not total gamepack size.
  1451.     nListResult = ListGetFirstItem (g_listComponentSizes, nComponentSize);
  1452.     nListResult = ListGetFirstString (g_listComponentDirectories, 
  1453.                       szComponentDir);
  1454.  
  1455.     // Ok, time to install each component now...
  1456.     while (END_OF_LIST != nListResult)
  1457.     if (nInstall) then
  1458.         // build the LOAD.DLL command line:
  1459.         //      <cpuType> <appName> <installDirectory> <totalBytesToCopy> <userName> <userCompany> <appLoadFile.load>
  1460.         Sprintf( szCmdLine, "\"%s\" \"%s\" \"%s\" %d \"%s\" \"%s\" \"%s\"", szPegasusCPU, szUninstall, SZ_DEST_DIR_PEGASUS,
  1461.              nComponentSize, szUserName, szUserCompany, szDestDirDesktop ^ szComponentDir ^ szLoadFile);
  1462.         //    MessageBox( szCmdLine, WARNING );
  1463.  
  1464.         // write the command line to a batch file
  1465.         /*
  1466.         if ( 0 = CreateFile( nFileHandle, szDestDirDesktop, "setup.bat" ) ) then
  1467.         szMsg1 = "load " + szCmdLine;
  1468.         WriteLine( nFileHandle, szMsg1 );
  1469.         CloseFile( nFileHandle );
  1470.         endif;
  1471.         */
  1472.  
  1473.  
  1474.         // check if the app already exists
  1475.         /* We will no longer do this. It's confusing, and really isn't a serious problem. This comment
  1476.            rseolves bug 13681, part 4. Yes, that's right. A single bug with 4 parts.
  1477.         if ( Load_AlreadyInstalled( SZ_PPCLOAD_APPNAME ) ) then
  1478.         szMsg1 = SZ_PRODUCT_NAME + " is already installed. You will lose the memory taken\n" + 
  1479.             "by the older installation if you do not remove it first (using 'Remove Programs'\n" +
  1480.             "on the HPC).\n\n" +
  1481.             "Continue installation?";
  1482.         if ( NO = AskYesNo( szMsg1, NO ) ) then
  1483.             Load_Exit();
  1484.             MessageBox( "Download stopped.", INFORMATION );
  1485.             CleanUp();
  1486.         endif;
  1487.         endif;
  1488.         */
  1489.  
  1490.         // use LOAD.DLL to download the app to Pegasus
  1491.         nRetErr = Load( hwndMine, szCmdLine );   // BUGBUG - must handle error code correctly
  1492.  
  1493.         if ( nRetErr != LOAD_SUCCESS ) then
  1494.         // we are not handling all the possible error cases - just the ones we need the user to know
  1495.         switch ( nRetErr )
  1496.             case LOAD_OUTOFSTORAGE:
  1497.             szErrCode = "There is not enough free storage memory on the HPC to install " + SZ_PRODUCT_NAME + ".\n" +
  1498.                                 "Please remove some files from the HPC or increase the\namount of storage memory available and run Setup again.";
  1499.             case LOAD_CANCELLEDBYUSER:
  1500.             szErrCode = "Application installation cancelled.";
  1501.             case LOAD_INVALID_PARAMETER:
  1502.             szErrCode = "The application installation received an invalid parameter.\n\nPlease run Setup again and ensure that all the information entered during Setup is correct.";
  1503.             case LOAD_DISCONNECTED:
  1504.             szErrCode = "Connection has been dropped.\n\nPlease check that the serial cable is connected to the desktop and the device, and DCC Manager is running.";
  1505.             case LOAD_CANT_CREATE_DIR:
  1506.             szErrCode = "A file on the HPC has the same name as the installed directory.\n\nPlease run Setup again, and choose a different installation directory.";
  1507.             default:
  1508.             szErrCode = "An unknown error occurred during the application installation.\n\nPlease ensure both the desktop and HPC are connected.";
  1509.         endswitch;
  1510.         MessageBox( szErrCode, SEVERE );
  1511.         nListResult = END_OF_LIST;            // Hey, we need to stop installing more components!
  1512.         nInstallResult = 0;                // Didn't complete installation
  1513.         endif;
  1514.     endif;
  1515.  
  1516.     // Get the next component
  1517.     if (END_OF_LIST != nListResult) then
  1518.             nListResult = ListGetNextString (g_listComponentNames, szAppName);
  1519.         nListResult = ListGetNextString (g_listComponentPPCLoadFile, szLoadFile);
  1520.         nListResult = ListGetNextString (g_listComponentUninstallName, szUninstall);
  1521.         nListResult = ListGetNextItem (g_listComponentsToInstall, nInstall);
  1522.         // 8/30/96 idobs: Bug fix.  Should pass component size to pccload, not total gamepack size.
  1523.         nListResult = ListGetNextItem (g_listComponentSizes, nComponentSize);
  1524.         nListResult = ListGetNextString (g_listComponentDirectories, 
  1525.                          szComponentDir);
  1526.     endif;
  1527.     endwhile;
  1528.  
  1529.     // Only tell user setup is complete if it worked!
  1530.     if (nInstallResult) then
  1531.     MessageBox( "Setup complete.  To run the PowerToys, select one from Start->Program Files->Accessories.", INFORMATION ); // $MODIFY
  1532.  
  1533.     szReadmeFile = SUPPORTDIR ^ "README.TXT";
  1534.     LongPathToShortPath( szReadmeFile );
  1535.     LaunchAppAndWait( "NOTEPAD.EXE " + szReadmeFile, "", NOWAIT);
  1536.     Delay(2);
  1537.     endif;
  1538.  
  1539.     // tim - make sure the icons for each exe transfered is updated here
  1540.     Load_RegisterFileInfo(SZ_PRODUCT_KEY_1, szDestDirDesktop ^ SZ_PRODUCT_SUBF_1 ^ SZ_ICON_FILE_1, "Application", 0); // BUGBUG ido
  1541.     Load_RegisterFileInfo(SZ_PRODUCT_KEY_2, szDestDirDesktop ^ SZ_PRODUCT_SUBF_2 ^ SZ_ICON_FILE_2, "Application", 0); // BUGBUG ido
  1542.     Load_RegisterFileInfo(SZ_PRODUCT_KEY_3, szDestDirDesktop ^ SZ_PRODUCT_SUBF_3 ^ SZ_ICON_FILE_3, "Application", 0); // BUGBUG ido
  1543.  
  1544.     szTemp = szFOLDER_STARTUP;      // "c:\windows\start menu\programs\startup\"
  1545.     StrRemoveLastSlash( szTemp );   // "c:\windows\start menu\programs\startup"
  1546.     ParsePath( szFolderDir, szTemp, PATH );
  1547.         // Because "szTemp" does not end with a backslash, ParsePath() will think that the last string
  1548.         // at the end of the path is a filename, so it will remove that string
  1549.     szFolderDir = szFolderDir ^ szREMOTE_CONTROL_FOLDER;   // append our "HPC Explorer" name to the end of "c:\windows\start menu\programs"
  1550.  
  1551.     LongPathToShortPath( szFolderDir );
  1552.  
  1553.     szTemp = szDestDirDesktop ^ szREMOTE_CONTROL_DOC;
  1554.     LongPathToQuote(szTemp, TRUE);
  1555.     AddFolderIcon( szFolderDir, szREMOTE_CONTROL_FOLDER_DOC, szTemp, "", "", 0, "", REPLACE);
  1556.     
  1557.     szTemp = szDestDirDesktop ^ szREMOTE_CONTROL_EXE;
  1558.     LongPathToQuote(szTemp, TRUE);
  1559.     AddFolderIcon( szFolderDir, szREMOTE_CONTROL_FOLDER_EXE, szTemp, "", "", 0, "", REPLACE);
  1560.  
  1561.  
  1562.     // uninitialize PPCLOAD.DLL
  1563.     Load_Exit();
  1564.  
  1565.     CleanUp();
  1566. end;
  1567.  
  1568.  
  1569. /*++
  1570.  
  1571.     CleanUp:
  1572.     - to de-allocate any dynamically-allocated lists
  1573.     - called before the program exits from normal execution or due to an error
  1574.  
  1575.     Arguments:
  1576.     None
  1577.  
  1578.     Return Value:
  1579.     None
  1580. --*/
  1581. function CleanUp()
  1582. begin
  1583.     // Clean up variables used for components!
  1584.     CleanUpComponentVars();
  1585.  
  1586.     UnUseDLL( g_szDllFilename );  // release the DLL from memory
  1587.     UnUseDLL( g_szDllFilename1 );  // release the DLL from memory
  1588.     exit;
  1589. end;
  1590.  
  1591. // required for all dialogs
  1592. #include "sddialog.rul"
  1593.