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