home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / xwplascr.zip / XWPL0208.ZIP / tools / repclass / repclass.c < prev   
C/C++ Source or Header  |  2002-02-26  |  5KB  |  129 lines

  1.  
  2. /*
  3.  * repclass.c:
  4.  *      this file contains the REPCLASS utility for registering
  5.  *      a new WPS class and replacing an existing class with it
  6.  *      in one step. The command-line syntax is:
  7.  *
  8.  *          repclass <oldclass> <newclass> [<dllname>]
  9.  *
  10.  *      If <dllname> is specified, <newclass> is registered and
  11.  *      replaces <oldclass>.
  12.  *
  13.  *      If <dllname> is omitted, the replacement of <oldclass>
  14.  *      with <newclass> is undone and <newclass> is de-registered.
  15.  *
  16.  *      Initial release: Aug. 12, 1998
  17.  *      Changed: 0.82. Made the output msgs a bit more lucid.
  18.  *      This version: 0.9.0. Updated the startup message.
  19.  */
  20.  
  21. /*
  22.  *      Copyright (C) 1997-2002 Ulrich Möller.
  23.  *      This program is free software; you can redistribute it and/or modify
  24.  *      it under the terms of the GNU General Public License as published by
  25.  *      the Free Software Foundation, in version 2 as it comes in the COPYING
  26.  *      file of the XWorkplace main distribution.
  27.  *      This program is distributed in the hope that it will be useful,
  28.  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
  29.  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  30.  *      GNU General Public License for more details.
  31.  */
  32.  
  33. #include <stdio.h>
  34. #include <os2.h>
  35.  
  36. #include "bldlevel.h"
  37.  
  38. /*
  39.  * main:
  40.  *      evaluate the command line, perform error checking
  41.  *      and do all the (de)registering and (un)replacing.
  42.  */
  43.  
  44. int main(int argc, char *argv[])
  45. {
  46.     int irc = 0;
  47.     /* The argv array will contain the following:
  48.      *         0         1          2            3
  49.      *      repclass <oldclass> <newclass> [<dllname>]
  50.      */
  51.  
  52.     BOOL rc1, rc2;
  53.  
  54.     if (argc == 4)
  55.     {
  56.         // four parameters: user wants registering.
  57.         // First register <newclass>
  58.         printf("Registering %s with the WPS class list: ", argv[2]);
  59.         if (WinRegisterObjectClass(argv[2], argv[3]))
  60.             printf("OK\n");
  61.         else
  62.         {
  63.             printf("failed!\n");
  64.             irc = 1;
  65.         }
  66.  
  67.         // Then replace <oldclass> with <newclass>.
  68.         printf ("Replacing %s with %s: ", argv[1], argv[2]);
  69.         if (WinReplaceObjectClass(argv[1], argv[2], TRUE))
  70.             printf("OK\n");
  71.         else
  72.         {
  73.             printf("failed!\n");
  74.             irc = 2;
  75.         }
  76.     }
  77.     else if (argc == 3)
  78.     {
  79.         // three parameters: user wants deregistering.
  80.         // First undo replacement of <oldclass> with <newclass>.
  81.         printf ("Un-replacing %s with %s: ", argv[2], argv[1]);
  82.         if (WinReplaceObjectClass(argv[1], argv[2], FALSE))
  83.             printf("OK\n");
  84.         else
  85.         {
  86.             printf("failed!\n");
  87.             irc = 3;
  88.         }
  89.  
  90.         // Then deregister <newclass>.
  91.         printf ("Deregistering %s: ", argv[2]);
  92.         if (WinDeregisterObjectClass(argv[2]))
  93.             printf("OK\n");
  94.         else
  95.         {
  96.             printf("failed!\n");
  97.             irc = 4;
  98.         }
  99.     }
  100.     else
  101.     {
  102.         // neither three nor four parameters: explain ourselves.
  103.         printf("repclass V"BLDLEVEL_VERSION" ("__DATE__") (C) 1998-2002 Ulrich Möller\n");
  104.         printf("  Part of the XWorkplace package.\n");
  105.         printf("  This is free software under the GNU General Public Licence (GPL).\n");
  106.         printf("  Refer to the COPYING file in the XWorkplace installation dir for details.\n");
  107.         printf("repclass registers and replaces a given Workplace Shell class or undoes an\n");
  108.         printf("existing replacement (and deregisters at the same time).\n");
  109.         printf("Usage: repclass <oldclass> <newclass> [<dllname>]\n");
  110.         printf("with:\n");
  111.         printf("   <oldclass>  being a currently installed WPS class;\n");
  112.         printf("   <newclass>  the name of the new class to replace <oldclass> with;\n");
  113.         printf("   <dllname>   the filename of the DLL which contains <newclass>; if the DLL\n");
  114.         printf("               is not on the LIBPATH, you must specify a full path.\n");
  115.         printf("If <dllname> is specified, <newclass> is registered with the WPS, and \n");
  116.         printf("  <oldclass> is replaced with it.\n");
  117.         printf("If <dllname> is omitted, <newclass> will be removed from the replacement list\n");
  118.         printf("  for <oldclass>, and <newclass> will be deregistered.\n");
  119.         printf("Class names are case-sensitive.\n");
  120.         printf("Examples:\n");
  121.         printf(" repclass WPFolder XFolder xfolder.dll - register XFolder and replace WPFolder\n");
  122.         printf(" repclass WPFolder XFolder        - deregister XFolder and un-replace WPFolder\n");
  123.         irc = 5;
  124.     }
  125.  
  126.     return (irc);
  127. }
  128.  
  129.