home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 December / PCO_1298.ISO / filesbbs / os2 / bubpd102.arj / BUBPD102.ZIP / Source / inst.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-19  |  28.7 KB  |  851 lines

  1. /***********************************************************************/
  2. /* Installation program for BubblePad                                  */
  3. /* (C) Chris Wohlgemuth                                                */
  4. /*                                                                     */
  5. /* E-Mail: chris.wohlgemuth@cityweb.de                                 */
  6. /*     or  christopher.wohlgemuth@bch.siemens.de                       */
  7. /*                                                                     */
  8. /* Released under the GNU Public Licence                               */
  9. /* See file COPYING for further information                            */
  10. /*                                                                     */
  11. /* 20.06.98 V1.00:  First public version                               */
  12. /* 16.08.98 V1.00a: Corrected bug which prevented accepting of default */
  13. /*                  installation directory on some systems             */
  14. /*                                                                     */
  15. /***********************************************************************/
  16.  
  17. #define INCL_WINWORKPLACE
  18. #define INCL_WINSHELLDATA
  19. #define INCL_DOSMISC       /* DOS Miscellaneous values */
  20. #define INCL_DOSERRORS     /* DOS Error values         */
  21. #define INCL_DOSMODULEMGR
  22. #define INCL_DOSFILEMGR
  23. #define INCL_DOS
  24.  
  25. #include <os2.h>
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <string.h>
  29.  
  30. #include <sys/video.h>
  31.  
  32. #define MAXLANGUAGES 5    //Num of possible languages
  33. #define USEDLANGUAGES 2   //Num of used Languages. Translate strings and increase
  34.  
  35. #define NUMERRORS 18 // Num of error msgs
  36. #define MAXERRORS MAXLANGUAGES*NUMERRORS
  37.  
  38. #define NUMACTIONS 3 //Install, deinstall, exit
  39.  
  40. #define NUMMSG 24
  41. #define MAXMSG MAXLANGUAGES*NUMMSG
  42.  
  43.  
  44. APIRET APIENTRY DosReplaceModule(PSZ old, PSZ newdll, PSZ backup);
  45.  
  46. void main(int argc, char *argv[])
  47. {
  48.     APIRET rc;
  49.     ULONG   aulSysInfo[QSV_MAX] = {0};       /* System Information Data Buffer */
  50.     char buffer[CCHMAXPATH];
  51.     char buffer2[CCHMAXPATH];
  52.     char drive;
  53.     char bootDrive;
  54.     HMODULE hmodule;
  55.     PSZ dllName=(UCHAR*)"BUBBLEPD";
  56.     PSZ helpName=(UCHAR*)"BUBBLEPD.HLP";
  57.     PSZ dllSource;    
  58.     PSZ helpSource;
  59.     
  60.     char error[CCHMAXPATH];
  61.     int attrib;
  62.     int x,wahl;
  63.     int lang;
  64.     
  65.     int offset;
  66.     int width;
  67.     int height;
  68.     int loop;
  69.     int start;//cursor
  70.     int end;//cursor
  71.     FILESTATUS3 filestatus3={{0}};
  72.     ULONG ulBufferSize=sizeof(FILESTATUS3);
  73.     ULONG ulDriveMap;
  74.     PSZ     envString;
  75.     
  76.     const selectColor=B_BLUE|F_WHITE;
  77.     const normalColor=B_BLACK|F_WHITE;
  78.     
  79.     int select[MAXLANGUAGES*2]={selectColor,normalColor,normalColor,normalColor};
  80.     
  81.     char fileName[MAXLANGUAGES*2][50]={
  82.         "Deutsch\\BUBBLEPD",
  83.         "English\\BUBBLEPD",
  84.         "Language_3\\BUBBLEPD",
  85.         "Language_4\\BUBBLEPD",
  86.         "Language_5\\BUBBLEPD",
  87.  
  88.         "Deutsch\\BUBBLEPD.hlp",
  89.         "English\\BUBBLEPD.hlp",
  90.         "Language_3\\BUBBLEPD.hlp",
  91.         "Language_4\\BUBBLEPD.hlp",
  92.         "Language_5\\BUBBLEPD.hlp"
  93.     };
  94.     
  95.     
  96.     char errstr[MAXERRORS][100]= {
  97.         //Deutsch
  98.         "Fehler!! DosQuerySysInfo: return code =",
  99.         "Kann Verzeichnis nicht finden. Lege Verzeichnis an...",
  100.         "Fehler: Can't create directory. Perhaps wrong name specified.     Exiting...",
  101.         "Fehler! DosQueryCurrentDisk rc =",
  102.         "Kann aktuelles Laufwerk nicht finden.  Ende...\n",
  103.         "Kann aktuelles Verzeichnis nicht finden.  Ende...\n",
  104.         "Fehler! DosCopy error #",
  105.         "Kann DLL nicht kopieren.  Ende...\n",
  106.         "WPLaunchPad-Klasse konnte nicht ersetzt werden!\n",
  107.         "Fehler während WinDeregisterObjectClass(). Nicht Deregistriert.    Ende...\n",
  108.         "Kann Klasse WPLnchCW nicht registrieren!\n",
  109.         "Kann Hilfe Verzeichnis nicht finden! 'Bubblepd.hlp' von Hand kopieren.\n\n",
  110.         "Kann Hilfedatei nicht kopieren!\n'Bubblepd.hlp' von Hand kopieren.\n\n",
  111.         "Fehler - Kann vorherige WPLaunchPad-Klasse nicht aktivieren!\n\n",
  112.         "Kann Hilfe Verzeichnis nicht finden! Datei 'BUBBLEPD.HLP' von Hand löschen.\n\n", 
  113.         "Kann Hilfedatei nicht löschen!\n'Bubblepd.hlp' von Hand löschen.\n\n",
  114.         "Kann Klassen-DLL %s nicht löschen!\n\n",
  115.         "Kann Einträge in user-ini nicht löschen!\n\n",
  116.  
  117.         //English
  118.         "DosQuerySysInfo error: return code =",
  119.         "Can't find directory. Creating Directory...",
  120.         "Error: Can't create directory. Perhaps wrong name specified.      Exiting...",
  121.         "DosQueryCurrentDisk error:",
  122.         "Can't get current drive.  Exiting...\n",
  123.         "Can't get current directory.  Exiting...\n",
  124.         "DosCopy error #",
  125.         "Can't copy classfile.     Exiting...\n",
  126.         "Can't replace WPLaunchPad!\n",
  127.         "WinDeregisterObjectClass() error.  Can't deregister Objectclass.  Exiting...\n",
  128.         "Can't register class WPLnchCW!\n",
  129.         "Can't find help-directory! Please copy file 'BUBBLEPD.HLP' by hand.\n\n",
  130.         "Can't copy helpfile!\nPlease copy file 'BUBBLEPD.HLP' by hand.\n\n", 
  131.         "Error - Can't activate previous class!\n\n",
  132.         "Error - Can't find help-directory! Please delete file 'BUBBLEPD.HLP' by hand.\n\n", 
  133.         "Can't delete helpfile!\nPlease delete file 'BUBBLEPD.HLP' by hand.\n\n",
  134.         "Can't delete classfile %s.\n",
  135.         "Can't delete user-ini entries!\n\n",
  136.         
  137.         //Language 3
  138.         "DosQuerySysInfo error: return code =",
  139.         "Can't find directory. Creating Directory...",
  140.         "Error: Can't create directory. Perhaps wrong name specified.      Exiting...",
  141.         "DosQueryCurrentDisk error:",
  142.         "Can't get current drive.  Exiting...\n",
  143.         "Can't get current directory.  Exiting...\n",
  144.         "DosCopy error #",
  145.         "Can't copy classfile.     Exiting...\n",
  146.         "Can't replace WPLaunchPad!\n",
  147.         "WinDeregisterObjectClass() error.  Can't deregister Objectclass.           Exiting...\n",
  148.         "Can't register class WPLnchCW!\n",
  149.         "Can't find help-directory! Please copy file 'BUBBLEPD.HLP' by hand.\n\n",
  150.         "Can't copy helpfile!\nPlease copy file 'BUBBLEPD.HLP' by hand.\n\n", 
  151.         "Error - Can't activate previous class!\n\n",
  152.         "Error - Can't find help-directory! Please delete file 'BUBBLEPD.HLP' by hand.\n\n", 
  153.         "Can't delete helpfile!\nPlease delete file 'BUBBLEPD.HLP' by hand.\n\n",
  154.         "Can't delete classfile %s.\n",
  155.         "Can't delete user-ini entries!\n\n",
  156.  
  157.         //Language 4
  158.         "DosQuerySysInfo error: return code =",
  159.         "Can't find directory. Creating Directory...",
  160.         "Error: Can't create directory. Perhaps wrong name specified.      Exiting...",
  161.         "DosQueryCurrentDisk error:",
  162.         "Can't get current drive.  Exiting...\n",
  163.         "Can't get current directory.  Exiting...\n",
  164.         "DosCopy error #",
  165.         " Can't copy classfile.    Exiting...\n",
  166.         "Can't replace WPLaunchPad!\n",
  167.         "WinDeregisterObjectClass() error.  Can't deregister Objectclass.  Exiting...\n",
  168.         "Can't register class WPLnchCW!\n",
  169.         "Can't find help-directory! Please copy file 'BUBBLEPD.HLP' by hand.\n\n",
  170.         "Can't copy helpfile!\nPlease copy file 'BUBBLEPD.HLP' by hand.\n\n", 
  171.         "Error - Can't activate previous class!\n\n",
  172.         "Error - Can't find help-directory! Please delete file 'BUBBLEPD.HLP' by hand.\n\n", 
  173.         "Can't delete helpfile!\nPlease delete file 'BUBBLEPD.HLP' by hand.\n\n",
  174.         "Can't delete classfile %s.\n",
  175.         "Can't delete user-ini entries!\n\n",
  176.  
  177.         //Language 5
  178.         "DosQuerySysInfo error: return code =",
  179.         "Can't find directory. Creating Directory...",
  180.         "Error: Can't create directory. Perhaps wrong name specified.      Exiting...",
  181.         "DosQueryCurrentDisk error:",
  182.         "Can't get current drive.  Exiting...\n",
  183.         "Can't get current directory.  Exiting...\n",
  184.         "DosCopy error #",
  185.         "Can't copy classfile.           Exiting...\n"
  186.         "Can't replace WPLaunchPad!\n",
  187.         "WinDeregisterObjectClass() error.  Can't deregister Objectclass.  Exiting...\n",
  188.         "Can't register class WPLnchCW!\n",
  189.         "Can't find help-directory! Please copy file 'BUBBLEPD.HLP' by hand.\n\n",
  190.         "Can't copy helpfile!\nPlease copy file 'BUBBLEPD.HLP' by hand.\n\n", 
  191.         "Error - Can't activate previous class!\n\n",
  192.         "Error - Can't find help-directory! Please delete file 'BUBBLEPD.HLP' by hand.\n\n", 
  193.         "Can't delete helpfile!\nPlease delete file 'BUBBLEPD.HLP' by hand.\n\n",
  194.         "Can't delete classfile %s.\n",
  195.         "Can't delete user-ini entries!\n\n"
  196.     };
  197.     
  198.     char language[MAXLANGUAGES*2][100]={
  199.         "Deutsch",//lang=0
  200.         "English",//lang=1
  201.         "Language 3",//lang=2
  202.         "Language 4",//lang=3
  203.         "Language 5",//lang=4
  204.  
  205.         "Pfeiltasten zum Auswählen, anschließend eine beliebige Taste drücken.",
  206.         "Use arrow keys to select then press any Key.",
  207.         "Translate it to language 3",
  208.         "Translate it to language 4",
  209.         "Translate it to language 5"
  210.     };
  211.  
  212.     char action[MAXLANGUAGES*(NUMACTIONS+1)][100]={
  213.         //Deutsch
  214.         "Installieren",
  215.         "Deinstallieren",
  216.         "Ende",
  217.         "Pfeiltasten zum Auswählen, anschließend <EINGABE>",
  218.         
  219.         //Englisch
  220.         "Install",
  221.         "Deinstall",
  222.         "Exit",
  223.         "Use arrow keys to select then press <RETURN>.",
  224.  
  225.         //Language 3
  226.         "Install",
  227.         "Deinstall",
  228.         "Exit",
  229.         "Use arrow keys to select then press <RETURN>.",
  230.  
  231.         //Language 4
  232.         "Install",
  233.         "Deinstall",
  234.         "Exit",
  235.         "Use arrow keys to select then press <RETURN>.",
  236.  
  237.         //Language 5
  238.         "Install",
  239.         "Deinstall",
  240.         "Exit",
  241.         "Use arrow keys to select then press <RETURN>."
  242.     };
  243.     
  244.     char msg[MAXMSG][100]= {
  245.         //Deutsch
  246.         "Installation von Bubblepad beginnt...",
  247.         "Suche Bootlaufwerk...",
  248.         "Installationsverzeichnis ist ",
  249.         "<EINGABE> drücken oder ein anderes Verzeichnis angeben (kein Backslash am Ende)\n--> ",
  250.         "Überprüfe Verzeichnis...",
  251.         "Kopiere Klassen-DLL...\n\n",
  252.         "Registriere neue Objektklasse WPLnchCW...\n",
  253.         "WPLnchCW  wurde registriert.\n\n",
  254.         "Ersetze alte Launchpad-Klasse...\n",
  255.         "Vorherige Launchpadklasse wurde ersetzt.\n\n",
  256.         "Deregistriere Klasse WPLnchCW...\n",
  257.         "Suche Verzeichnis für Hilfe-Dateien...\n",
  258.         "Lösche Klassen-DLL.         Breche ab...\n\n",
  259.         "Kopiere Hilfe-Datei.\n\n",
  260.         "Die zusätzliche Funktionalität steht nach einem Reboot zur Verfügung.",
  261.         "Aktiviere vorherige Launchpad-Klasse...\n",
  262.         "Vorherige Klasse wurde wieder aktiviert.\n\n",
  263.         "Lösche Klassen-DLL %s...\n",
  264.         "Fertig - WPLnchCW  wurde deregistriert.\n\n",
  265.         "Bei einem Neustart wird die Klasse endgültig aus dem Speicher entfernt.\n\n",
  266.         "--- Unbenutzt ---\n",
  267.         "<STRG-c> zum Abbrechen oder <Eingabe>.\n\n",
  268.         "Installation von Bubblepad (c) Chris Wohlgemuth 1997-98",
  269.         "Vor der Installation die Datei COPYING lesen!!",
  270.         
  271.         //English
  272.         "Starting installation...",        
  273.         "Quering bootdrive...",
  274.         "Installation directory is ",
  275.         "Press <ENTER> or type in another directory \n--> ",
  276.         "Checking directory...",
  277.         "Copying Class-dll...\n\n",
  278.         "Registering new objectclass WPLnchCW...\n",
  279.         "Ready.\n\n",
  280.         "Replacing old Launchpad-class...\n",
  281.         "Ready.\n\n",
  282.         "Deregistering class WPLnchCW...\n",
  283.         "Querying help-directory...\n",
  284.         "Deleting class-file.    Exiting...\n\n",
  285.         "Copying help-file.\n\n",
  286.         "Reboot to activate the enhancement.",
  287.         "Activating previous Launchpad-class...\n",
  288.         "Previous class is activated.\n\n",
  289.         "Deleting class-file %s...\n",
  290.         "Ready - Deregistered objectclass WPLnchCW.\n\n",
  291.         "The class will be deleted from memory after a reboot.\n\n",
  292.         "---unused ---\n",
  293.         "Press <CTRL-c> to abort or <Return> to continue.\n\n",
  294.         "Installation of Bubblepad (c) Chris Wohlgemuth 1997-98",
  295.         "Read the file COPYING before installation!!",
  296.  
  297.         //Language 3
  298.         "Starting installation...",
  299.         "Quering bootdrive...",
  300.         "Installation directory is ",
  301.         "Press <ENTER> or type in another directory \n--> ",
  302.         "Checking directory...",
  303.         "Copying Class-dll...\n\n",
  304.         "Registering new objectclass WPLnchCW...\n",
  305.         "Ready.\n\n",
  306.         "Replacing old Launchpad-class...\n",
  307.         "Ready.\n\n",
  308.         "Deregistering class WPLnchCW...\n",
  309.         "Querying help-directory...\n",
  310.         "Deleting class-file.    Exiting...\n\n",
  311.         "Copying help-file.\n\n",
  312.         "Reboot to activate the enhancement.",
  313.         "Activating previous Launchpad-class...\n",
  314.         "Previous class is activated.\n\n",
  315.         "Deleting class-file %s...\n",
  316.         "Ready - Deregistered objectclass WPLnchCW.\n\n",
  317.         "The class will be deleted from memory after a reboot.\n\n",
  318.         "---unused ---\n",
  319.         "Press <CTRL-c> to abort or <Return> to continue.\n\n",
  320.         "Installation of Bubblepad (c) Chris Wohlgemuth 1997-98",
  321.         "Read the file COPYING before installation!!",
  322.  
  323.         //Language 4            
  324.         "Starting installation...",
  325.         "Quering bootdrive...",
  326.         "Installation directory is ",
  327.         "Press <ENTER> or type in another directory \n--> ",
  328.         "Checking directory...",
  329.         "Copying Class-dll...\n\n",
  330.         "Registering new objectclass WPLnchCW...\n",
  331.         "Ready.\n\n",
  332.         "Replacing old Launchpad-class...\n",
  333.         "Ready.\n\n",
  334.         "Deregistering class WPLnchCW...\n",
  335.         "Querying help-directory...\n",
  336.         "Deleting class-file.    Exiting...\n\n",
  337.         "Copying help-file.\n\n",
  338.         "Reboot to activate the enhancement.",
  339.         "Activating previous Launchpad-class...\n",
  340.         "Previous class is activated.\n\n",
  341.         "Deleting class-file %s.",
  342.         "Ready - Deregistered objectclass WPLnchCW.\n\n",
  343.         "The class will be deleted from memory after a reboot.\n\n",
  344.         "---unused ---\n",
  345.         "Press <CTRL-c> to abort or <Return> to continue.\n\n",
  346.         "Installation of Bubblepad (c) Chris Wohlgemuth 1997-98",
  347.         "Read the file COPYING before installation!!",
  348.             
  349.         //Language 5
  350.         "Starting installation...",
  351.         "Quering bootdrive...",
  352.         "Installation directory is ",
  353.         "Press <ENTER> or type in another directory \n--> ",
  354.         "Checking directory...",
  355.         "Copying Class-dll...\n\n",
  356.         "Registering new objectclass WPLnchCW...\n",
  357.         "Ready.\n\n"
  358.         "Replacing old Launchpad-class...\n",
  359.         "Ready.\n\n",
  360.         "Deregistering class WPLnchCW...\n",
  361.         "Querying help-directory...\n",
  362.         "Deleting class-file.    Exiting...\n\n",
  363.         "Copying help-file.\n\n"
  364.         "Reboot to activate the enhancement.",    
  365.         "Activating previous Launchpad-class...\n",
  366.         "Previous class is activated.\n\n",
  367.         "Deleting class-file %s.",
  368.         "Ready - Deregistered objectclass WPLnchCW.\n\n",
  369.         "The class will be deleted from memory after a reboot.\n\n",
  370.         "---unused ---\n",
  371.         "Press <CTRL-c> to abort or <Return> to continue.\n\n",
  372.         "Installation of Bubblepad (c) Chris Wohlgemuth 1997-98",
  373.         "Read the file COPYING before installation!!"
  374.  
  375.     };
  376.     
  377.     for(x=0;x<MAXLANGUAGES*2;x++) {
  378.         select[x]=normalColor;
  379.     }
  380.     
  381.     offset=0;
  382.     x=0;
  383.     wahl=0;
  384.     select[0]=selectColor;
  385.  
  386.     v_init();
  387.     v_clear();
  388.     v_dimen(&width,&height);
  389.     v_getctype(&start,&end);
  390.     
  391.     v_hidecursor();
  392.  
  393.     /*****************************************************************************/
  394.     /* Language selection                                                        */
  395.     /*****************************************************************************/    
  396.     while(!wahl) {
  397.         for(loop=0;loop<USEDLANGUAGES;loop++) {
  398.             /*  Items                                                                                                                                       */
  399.             v_gotoxy((width-strlen(language[0+loop]))/2,5+loop);
  400.             v_attrib(select[0+loop]);
  401.             v_printf("%s\n",language[0+loop]);
  402.             /*  Explanation                                       */
  403.             v_attrib(select[0+MAXLANGUAGES+loop]);
  404.             v_gotoxy((width-strlen(language[0+MAXLANGUAGES+loop]))/2,height-1-MAXLANGUAGES+loop);
  405.             v_printf(language[0+MAXLANGUAGES+loop]);
  406.         }
  407.         rc=_read_kbd(0,1,1);
  408.         wahl=1;
  409.         if(!rc){
  410.             rc=_read_kbd(0,1,1);
  411.             if(rc==72||rc==80) {
  412.                 select[x]=normalColor;
  413.                 if(rc==72){
  414.                     x--;
  415.                     if(x<0)x=USEDLANGUAGES-1;
  416.                 }
  417.                 else{
  418.                     x++;
  419.                     if(x==USEDLANGUAGES)x=0;
  420.                 }
  421.                 select[x]=selectColor;
  422.             }
  423.             wahl=0;
  424.         }
  425.     }
  426.     lang=x;
  427.  
  428.     dllSource=(UCHAR *)fileName[lang];
  429.     helpSource=(UCHAR *)fileName[MAXLANGUAGES+lang];
  430.     
  431.     /*****************************/
  432.     /* Show Copyright            */
  433.     /*****************************/    
  434.     v_clear();
  435.     v_gotoxy((width-strlen(msg[lang*NUMMSG+22]))/2,2);    
  436.     v_attrib(selectColor);
  437.     v_printf(msg[lang*NUMMSG+22]);//show copyright
  438.     v_attrib(B_RED|F_WHITE);     
  439.     v_gotoxy((width-strlen(msg[lang*NUMMSG+23]))/2,4);    
  440.     v_printf(msg[lang*NUMMSG+23]);//show licence msg
  441.     v_attrib(normalColor);
  442.     v_gotoxy((width-strlen(msg[lang*NUMMSG+21]))/2,15);
  443.     v_printf(msg[lang*NUMMSG+21]);
  444.     rc=_read_kbd(0,1,1);
  445.  
  446.     /*****************************************************************************/
  447.     /* Select action                                                             */
  448.     /*****************************************************************************/    
  449.     v_clear();
  450.     offset=lang*(NUMACTIONS+1);
  451.     wahl=0;
  452.     x=offset;
  453.     select[x]=selectColor;
  454.  
  455.     /* Selection */    
  456.     while(!wahl) {
  457.         for(loop=0;loop<NUMACTIONS;loop++) {
  458.             /*  Items                                                                                                                                       */
  459.             v_gotoxy((width-strlen(action[offset+loop]))/2,5+loop);
  460.             v_attrib(select[offset+loop]);
  461.             v_printf("%s\n",action[offset+loop]);
  462.         }
  463.         /*  Explanation                                       */
  464.         v_attrib(normalColor);
  465.         v_gotoxy((width-strlen(action[offset+NUMACTIONS]))/2,height-1-NUMACTIONS);
  466.         v_printf(action[offset+NUMACTIONS]);                        
  467.         rc=_read_kbd(0,1,1);
  468.         wahl=1;
  469.         if(!rc){
  470.             rc=_read_kbd(0,1,1);
  471.             if(rc==72||rc==80) {
  472.                 select[x]=normalColor;
  473.                 if(rc==72){
  474.                     x--;
  475.                     if(x<0)x=NUMACTIONS-1;
  476.                 }
  477.                 else{
  478.                     x++;
  479.                     if(x==NUMACTIONS)x=0;
  480.                 }
  481.                 select[x]=selectColor;
  482.             }
  483.             wahl=0;
  484.         }
  485.     }
  486.     if(x==offset+NUMACTIONS-1) {
  487.         v_clear();
  488.         exit(0);//Exit choosen
  489.     }
  490.     
  491.     /*****************************************************************************/
  492.     /* Start Deinstallation                                                      */
  493.     /*****************************************************************************/    
  494.     if(x==offset+NUMACTIONS-2) {
  495.         v_clear();//Clear Screen
  496.         /*---------------  Query bootdrive    -----------------------------*/
  497.         offset=lang*NUMMSG+1;
  498.         rc = DosQuerySysInfo(1L,                 /* Request all available system   */
  499.                                                  QSV_MAX,            /* information                    */
  500.                                                  (PVOID)aulSysInfo,
  501.                                                  sizeof(ULONG)*QSV_MAX);
  502.         
  503.         if (rc != NO_ERROR) {//Error!!
  504.             v_attrib(B_RED|F_WHITE);
  505.             v_gotoxy((width-strlen(msg[offset]))/2,10);
  506.             sprintf(buffer2,"%s %u",errstr[lang*NUMERRORS],rc);
  507.             v_printf(buffer2);
  508.             exit(1);
  509.         } else {
  510.             drive='A';
  511.             drive+=aulSysInfo[QSV_BOOT_DRIVE-1]-1;//Found driveletter
  512.         } /* endif */
  513.         bootDrive=drive;        
  514.  
  515.         HMODULE handle;
  516.         char dll[CCHMAXPATH];
  517.         /* find class-dll */        
  518.         rc=DosLoadModule((PSZ) error,sizeof(error),(PSZ)dllName,&handle);    
  519.         if (rc==NO_ERROR){
  520.             DosQueryModuleName(handle,sizeof(dll),dll);
  521.             DosFreeModule(handle);
  522.         }
  523.         
  524.         v_gotoxy(0,2);
  525.         v_printf("%s",msg[lang*NUMMSG+15]);//Show message: unreplacing launchpad-class
  526.         /* Dereplace LaunchPad */
  527.         if(WinReplaceObjectClass((UCHAR*)"WPLaunchPad",(UCHAR*)"WPLnchCW",FALSE))
  528.             v_printf(msg[lang*NUMMSG+16]);//Show message: Activated previous class
  529.         else {
  530.             v_gotoxy(0,height-4);
  531.             v_attrib(B_RED|F_WHITE);
  532.             v_printf(errstr[lang*NUMERRORS+13]);//Error: Can't activate previous class
  533.             v_attrib(normalColor);
  534.             DosBeep(100,500);
  535.             exit(1);
  536.         }
  537.         /* Deregister objectclass */
  538.         v_printf("%s",msg[lang*NUMMSG+10]);//Show message: Deregistering WPLnchCW-class
  539.         if(WinDeregisterObjectClass((UCHAR*)"WPLnchCW"))//printf("WPLnchCW-Klasse wurde deregistriert.\n");
  540.             v_printf(msg[lang*NUMMSG+18]);//Show message: WPLnchCW-class is deregistered
  541.         else{
  542.             v_gotoxy(0,height-4);
  543.             v_attrib(B_RED|F_WHITE);
  544.             v_printf(errstr[lang*NUMERRORS+9]);//Error: Can't deregister class
  545.             v_attrib(normalColor);
  546.             DosBeep(100,500);
  547.             exit(1);
  548.         }
  549.  
  550.         /* Clear user.ini entries */
  551.         if(!PrfWriteProfileData(HINI_USERPROFILE,(UCHAR *)"WPLnchCW",NULL,NULL,0)) {
  552.             v_gotoxy(0,height-4);
  553.             v_attrib(B_RED|F_WHITE);
  554.             v_printf(errstr[lang*NUMERRORS+17]);// Error DosDelete()
  555.             DosBeep(100,500);
  556.             v_attrib(normalColor);
  557.             DosSleep(2000);
  558.             v_printf("\n\n\n\n");            
  559.         }
  560.         
  561.         /* Delete class-dll */
  562.         PFN procAddr;
  563.         
  564.         rc=DosLoadModule((PSZ) error,sizeof(error),(PSZ)"DOSCALLS.DLL",&handle);
  565.         if (rc!=NO_ERROR){
  566.             printf("DosLoadModule(DOSCALLS.DLL)-Error");
  567.             v_gotoxy(0,height-4);
  568.             v_attrib(B_RED|F_WHITE);
  569.             sprintf(buffer2,errstr[lang*NUMERRORS+16],dll);// Error
  570.             v_printf(buffer2);
  571.             DosBeep(100,500);
  572.             v_attrib(normalColor);
  573.             DosSleep(2000);
  574.             v_printf("\n\n\n\n");
  575.         }
  576.         else {
  577.             rc=DosQueryProcAddr(handle,417,(PSZ)"",&procAddr);
  578.             if (rc!=NO_ERROR)printf("DosQueryProcAddr-Error");
  579.             else{
  580.                 sprintf(buffer2,msg[lang*NUMMSG+17],dll);// Show message: Deleting classfile
  581.                 v_printf(buffer2);
  582.                 rc=procAddr((PSZ) dll,(PSZ) NULL,(PSZ) NULL);//Unlock DLL
  583.                 rc=DosDelete((UCHAR*)dll);//Delete DLL
  584.                 if (rc){
  585.                     v_gotoxy(0,height-4);
  586.                     v_attrib(B_RED|F_WHITE);
  587.                     sprintf(buffer2,errstr[lang*NUMERRORS+16],dll);// Error DosDelete()
  588.                     v_printf(buffer2);
  589.                     DosBeep(100,500);
  590.                     v_attrib(normalColor);
  591.                     DosSleep(2000);
  592.                     v_printf("\n\n\n\n");
  593.                 }            
  594.             }
  595.             if(handle)DosFreeModule(handle);
  596.         }
  597.         
  598.         /* Delete help file */ 
  599.         
  600.         /* Build helpdirectory name    (destination)                                                                                                   */
  601.         sprintf(buffer2,"%c:\\os2\\help",bootDrive);
  602.         /* Check helpdirectory for existance */
  603.         ulBufferSize=sizeof(FILESTATUS3);     
  604.         rc=DosQueryPathInfo((UCHAR*)buffer2,FIL_STANDARD,&filestatus3,ulBufferSize);
  605.         if(rc!=NO_ERROR) {
  606.             v_gotoxy(0,height-4);
  607.             v_attrib(B_RED|F_WHITE);
  608.             v_printf(errstr[lang*NUMERRORS+14]);
  609.             v_attrib(normalColor);
  610.             DosBeep(100,500);
  611.             exit(1);
  612.         }
  613.      
  614.         /* Build helpfile name    (destination)                                                                                                   */
  615.         sprintf(buffer2,"%c:\\os2\\help\\%s",bootDrive,helpName);
  616.         rc=DosDelete((UCHAR*)buffer2);
  617.         if(rc) {
  618.             v_gotoxy(0,height-4);
  619.             v_attrib(B_RED|F_WHITE);
  620.             v_printf(errstr[lang*NUMERRORS+15]);//Error: Can't delete help file    
  621.             v_attrib(normalColor);
  622.             DosBeep(100,500);
  623.             exit(1);
  624.         }
  625.         v_printf(msg[lang*NUMMSG+19]);
  626.         exit(0);//Exit
  627.     }
  628.     
  629.  
  630.     /*****************************************************************************/
  631.     /* Start installation                                                        */
  632.     /*****************************************************************************/    
  633.      v_clear();//Clear Screen
  634.     
  635.     offset=lang*NUMMSG;
  636.     
  637.     v_gotoxy((width-strlen(msg[offset]))/2,1);
  638.     v_attrib(normalColor);
  639.     v_printf("%s\n",msg[offset]);
  640.     
  641.     /*---------------  Query bootdrive    -----------------------------*/
  642.     offset=lang*NUMMSG+1;
  643.     v_gotoxy((width-strlen(msg[offset]))/2,10);
  644.     v_attrib(normalColor);
  645.     v_printf("%s\n",msg[offset]);//Show message "Quering bootdrive..."
  646.     DosSleep(200);
  647.     
  648.     rc = DosQuerySysInfo(1L,                 /* Request all available system   */
  649.                                              QSV_MAX,            /* information                    */
  650.                                              (PVOID)aulSysInfo,
  651.                                              sizeof(ULONG)*QSV_MAX);
  652.     
  653.     if (rc != NO_ERROR) {//Error!!
  654.         v_attrib(B_RED|F_WHITE);
  655.         v_gotoxy((width-strlen(msg[offset]))/2,10);
  656.         sprintf(buffer2,"%s %u",errstr[lang*NUMERRORS],rc);
  657.         v_printf(buffer2);
  658.         exit(1);
  659.     } else {
  660.         drive='A';
  661.         drive+=aulSysInfo[QSV_BOOT_DRIVE-1]-1;//Found driveletter
  662.     } /* endif */
  663.     bootDrive=drive;
  664.     
  665.     v_gotoxy(0,10);
  666.      v_attrib(normalColor);
  667.      v_clreol();//Clear message
  668.  
  669.      /* Show the destination directory name:    <bootdrive>:\os2\dll\                       */
  670.      offset=lang*NUMMSG+2;//next string:         "Installation directory is "
  671.      sprintf(buffer2,"%c:\\os2\\dll",drive);
  672.      v_gotoxy(0,height-5);
  673.      v_printf(msg[offset]);
  674.      v_attrib(selectColor);//directoryname
  675.      v_printf(buffer2);
  676.      
  677.      /* Ask for another directory                                                                                           */
  678.      offset=lang*NUMMSG+3;//next string
  679.      v_attrib(normalColor);
  680.      v_gotoxy(0,height-4);
  681.      v_printf(msg[offset]);//"Press <ENTER> or type in another directory: ",
  682.      v_ctype(start,end);
  683.      fgets(error,sizeof(error),stdin);
  684.      if(strlen(error)!=1)//1=Newline that is <ENTER>
  685.          sscanf(error,"%s",buffer);
  686.      else
  687.  
  688.          /*v_gotoxy(0,height-4);
  689.              v_attrib(normalColor);
  690.              v_clreol();//clear directory question
  691.              v_printf("Stringlength: %d  %s\n",strlen(buffer),buffer);
  692.              DosSleep(5000);*/
  693.      
  694.          //if(strlen(buffer)==0)
  695.          strcpy(buffer,buffer2);//put directoryname in buffer
  696.      v_gotoxy(0,height-4);
  697.      v_attrib(normalColor);
  698.      v_clreol();//clear directory question
  699.      v_gotoxy(0,height-3);
  700.      v_attrib(normalColor);
  701.      v_clreol();//clear prompt
  702.      v_gotoxy(0,height-5);
  703.      v_clreol();//clear previous directory name
  704.      v_printf(msg[offset-1]);
  705.      v_attrib(selectColor);
  706.      v_printf(buffer);//Show the directory name
  707.  
  708.      /* Check existance of destination directory                                                        */
  709.      v_gotoxy(0,height-4);
  710.      v_attrib(normalColor);
  711.      offset=lang*NUMMSG+4;
  712.      v_printf(msg[offset]);//show message what we are doing: "Checking directory..."
  713.  
  714.      rc=DosQueryPathInfo((UCHAR*)buffer,FIL_STANDARD,&filestatus3,ulBufferSize);
  715.      DosSleep(1000);
  716.  
  717.      if(rc!=NO_ERROR){//Error with the chosen directory
  718.          v_gotoxy(0,height-4);
  719.          v_clreol();
  720.          v_printf(errstr[lang*NUMERRORS+1]);
  721.          /*  Create directory                                                                                                               */ 
  722.          rc=DosCreateDir((UCHAR*)buffer,NULL);                  
  723.          if(rc!=NO_ERROR) {
  724.              DosSleep(1000);             
  725.              v_gotoxy(0,height-4);
  726.              v_clreol();
  727.              v_attrib(B_RED|F_WHITE);
  728.              v_gotoxy(0,height-4);
  729.              v_printf(errstr[lang*NUMERRORS+2]);
  730.              DosBeep(100,500);
  731.              exit(1);
  732.          }         
  733.      };
  734.  
  735.      sprintf(buffer2,"%s\\%s.dll",buffer,dllName);//Build full destinationpathname
  736.      /*------- Get current disk    -----------------------------------------*/
  737.      ulBufferSize=0;
  738.      drive='A';
  739.      rc=DosQueryCurrentDisk(&ulBufferSize,&ulDriveMap);
  740.      if(rc!=NO_ERROR) {
  741.          v_gotoxy(0,height-4);
  742.          v_attrib(B_RED|F_WHITE);
  743.          sprintf(buffer2,"%s %u. %s",errstr[lang*NUMERRORS+3],rc,errstr[lang*NUMERRORS+4]);
  744.          v_printf(buffer2);
  745.          DosBeep(100,500);
  746.          exit(1);
  747.      }
  748.      drive+=ulBufferSize-1;
  749.      /*------------- get current dir    ---------------------------------*/
  750.      ulBufferSize=sizeof(error);
  751.      rc=DosQueryCurrentDir(0,(UCHAR*)error,&ulBufferSize);     
  752.      if(rc!=NO_ERROR) {
  753.          v_gotoxy(0,height-4);
  754.          v_attrib(B_RED|F_WHITE);
  755.          sprintf(buffer2,"%s %u. %s",errstr[lang*NUMERRORS+3],rc,errstr[lang*NUMERRORS+5]);
  756.          v_printf(buffer2);
  757.          DosBeep(100,500);
  758.          exit(1);
  759.      }
  760.      /* Build source path */
  761.      sprintf(buffer,"%c:\\%s\\%s.dll",drive,error,dllSource);     
  762.      offset=lang*NUMMSG+5;
  763.      v_clear(); 
  764.      v_gotoxy(0,2);
  765.      v_printf(msg[offset]);//say what we are doing: "Copy Class-dll..."
  766.      
  767.      /* copy classfile to destination */
  768.      rc=DosCopy((UCHAR*)buffer,(UCHAR*)buffer2,DCPY_EXISTING);
  769.      if(rc!=NO_ERROR) {
  770.          v_gotoxy(0,height-4);
  771.          v_attrib(B_RED|F_WHITE);
  772.          sprintf(buffer2,"%s%u. %s",errstr[lang*NUMERRORS+6],rc,errstr[lang*NUMERRORS+7]);
  773.          v_printf(buffer2);
  774.          DosBeep(100,500);
  775.          exit(1);
  776.      }
  777.  
  778.      /* Register objectclass                                                                                                   */
  779.      v_printf(msg[lang*NUMMSG+6]);//say what we are doing: register Objectclass
  780.      if(WinRegisterObjectClass((UCHAR*)"WPLnchCW",(UCHAR*)buffer2)) {
  781.          v_printf(msg[lang*NUMMSG+7]);//say what we have done: registered Objectclass
  782.          v_printf(msg[lang*NUMMSG+8]);//say what we are doing: replacing WPLaunchPad
  783.          if(WinReplaceObjectClass((UCHAR*)"WPLaunchPad",(UCHAR*)"WPLnchCW",TRUE)){
  784.              v_printf(msg[lang*NUMMSG+9]);//say what we have done: replaced WPLaunchPad
  785.          }
  786.          else{//Can't replace LaunchPad
  787.              v_attrib(B_RED|F_WHITE);
  788.              v_printf(errstr[lang*NUMERRORS+8]);
  789.              v_attrib(normalColor);             
  790.              v_printf(msg[lang*NUMMSG+10]);//say what we are doing: deregister Objectclass
  791.              if(!WinDeregisterObjectClass((UCHAR*)"WPLnchCW")){
  792.                  v_gotoxy(0,height-4);
  793.                  v_attrib(B_RED|F_WHITE);
  794.                  v_printf(errstr[lang*NUMERRORS+9]);
  795.                  DosBeep(100,500);
  796.              }
  797.              exit(1);                
  798.          }
  799.      }//end of if(WinRegisterObjectClass((UCHAR*)"WPLnchCW",(UCHAR*)buffer2))
  800.      else {//Can't register WPLnchCW-class
  801.          v_gotoxy(0,height-4);
  802.          v_attrib(B_RED|F_WHITE);
  803.          v_printf(errstr[lang*NUMERRORS+10]);
  804.          DosBeep(100,500);
  805.          v_attrib(normalColor);
  806.          v_printf(msg[lang*NUMMSG+12]);
  807.          rc=DosDelete((UCHAR*)buffer2);
  808.          exit(1);
  809.      }         
  810.  
  811.      v_printf(msg[lang*NUMMSG+11]);//say what we are doing: Search help-Directory
  812.      /* Build helpfile name    (source)                                                                                                   */
  813.      sprintf(buffer,"%c:\\%s\\%s",drive,error,helpSource);
  814.      /* Build helpdirectory name    (destination)                                                                                                   */
  815.      sprintf(buffer2,"%c:\\os2\\help",bootDrive);
  816.      /* Check helpdirectory for existance */
  817.      ulBufferSize=sizeof(FILESTATUS3);     
  818.      rc=DosQueryPathInfo((UCHAR*)buffer2,FIL_STANDARD,&filestatus3,ulBufferSize);
  819.      if(rc!=NO_ERROR) {
  820.          v_gotoxy(0,height-4);
  821.          v_attrib(B_RED|F_WHITE);
  822.          v_printf(errstr[lang*NUMERRORS+11]);
  823.          v_attrib(normalColor);
  824.          exit(1);
  825.      }
  826.      
  827.      /* Build helpfile name    (destination)                                                                                                   */
  828.      sprintf(buffer2,"%c:\\os2\\help\\%s",bootDrive,helpName);
  829.      /*  Copy help-file                                                                                                                   */
  830.      v_printf(msg[lang*NUMMSG+13]);//say what we are doing: copy help-file
  831.  
  832.      rc=DosCopy((UCHAR*)buffer,(UCHAR*)buffer2,DCPY_EXISTING);
  833.      rc=0;
  834.           
  835.      if(rc!=NO_ERROR) {
  836.          v_gotoxy(0,height-4);
  837.          v_attrib(B_RED|F_WHITE);
  838.          sprintf(buffer2,"%s %u. %s",errstr[lang*NUMERRORS+6],rc,errstr[lang*NUMERRORS+12]);
  839.          v_printf(buffer2);
  840.          //         v_printf("DosCopy error #%u: Can't copy helpfile.           Exiting...\n",rc);
  841.          v_attrib(normalColor);
  842.          DosBeep(100,500);
  843.          exit(1);
  844.      }    
  845.      v_attrib(selectColor);
  846.      v_printf(msg[lang*NUMMSG+14]);//say please reboot     
  847.      v_attrib(normalColor);
  848.      v_printf("\n\n");        
  849.      exit(0);          
  850. }
  851.