You can provide installation programs for your objects. An installation program is responsible for:

An example of an installation program for a Workplace Shell object is shown in the following sample code:

/* Command-line program to install Workplace Shell objects  */
#define INCL_WINWORKPLACE
#include <os2.h>
#include <stdio.h>
#include <string.h>

#if defined(DEBUG)
   #define LOCATION_DESKTOP ((PSZ)"<WP_DESKTOP>")
#endif

/*
 *  Main Function
 *
 *    argv[1] = Class Name
 *    argv[2] = Module (DLL) Name
 *    argv[3] = Object Title
 *    argv[4] = Location
 *    argv[5] = Setup String
 */

INT main (argc, argv)
   INT argc;
   CHAR *argv[];

{
  HAB vhab;
  HMQ vhmq;
  BOOL fSuccess;

  if (argc == 1)
  {
    #if defined(DEBUG)
    {
      printf("Usage:\n\n");
      printf("   WPCREATE ClassName ModuleName Title [[Location]
             [SetupString]]\n");
    }
    #endif
    return (0);
  } /* End if (argc == 1) */

  if (argc < 4) return (1);   /* First three parms are mandatory */

  /* Register the class  */
  #if defined(DEBUG)
    printf("WinRegisterObjectClass(%s, %s)...\n", argv[1], argv[2]);
  #endif

  fSuccess = WinRegisterObjectClass(
                argv[1],    /* Class name (case sensitive) */
                argv[2]);   /* Module name                 */

  if (!fSuccess) return (1);   /* Return non-zero for error */

  #if defined(DEBUG)
    printf("Success: rc = %u\n", fSuccess);
  #endif

  /*  Create an instance of the object  */
  #if defined(DEBUG)
    printf("WinCreateObject(%s, %s,...)...\n", argv[1], argv[3]);
  #endif
  fSuccess = WinCreateObject(
                argv[1],                                 /* Class name   */
                argv[3],                                 /* Object title */
                argc > 5 ? argv[5] : " ",                /* Setup string */
                argc > 4 ? argv[4] : LOCATION_DESKTOP,   /* Location     */
                CO_FAILIFEXISTS);                        /* Flags        */

  if (!fSuccess) return (1);   /* Return non-zero for error */

  #if defined(DEBUG)
    printf("Success: rc = %u\n", fSuccess);
  #endif

  return(0);

}   /* End main() */

Instantiating an object is an optional responsibility of an installation program. When a class is registered by calling WinRegisterObjectClass, an object template is placed in the Templates folder on the Desktop, if the class supports templating. Users can create instances of these objects by tearing off a copy of the template. This can be useful for larger applications that define data-file objects that are associated with program objects.


[Back] [Next]