home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / tutsamp / dllserve / dllserve.txt < prev    next >
Text File  |  1997-08-05  |  7KB  |  134 lines

  1.  
  2. DLLSERVE - COM Server in a DLL
  3.  
  4.  
  5. SUMMARY
  6. =======
  7.  
  8. The COMOBJ sample introduced COM objects. This DLLSERVE sample introduces
  9. COM components (also called simply component objects). A component object
  10. is a reusable software unit that encapsulates or packages the
  11. manufacturing of a specific class of COM object. A COM object class
  12. specifies an open-ended set of behaviorally identical COM objects that is
  13. uniquely identified for all programs and all time (by a Class ID).
  14.  
  15. Component objects are housed in a COM Server. The server executable is
  16. registered (or published) in a system registry to act as the creation
  17. agent for COM object instances of the COM Component. The server contains
  18. one or more Class Factories used for the creation of COM objects. Class
  19. factories are themselves COM objects that expose the IClassfactory[2]
  20. interface.  However, as an integral part of the server housing, class
  21. factories are typically not full-fledged component objects.
  22.  
  23. Component objects are the building blocks in COM and ActiveX programming.
  24. Component objects are combined to make some portion of an application. The
  25. running behavior of the applicaion is often determined by, and evidenced
  26. in, the COM objects that were instantiated (i.e., that were manufactured
  27. in the class factories of the various component objects that were combined
  28. in the application).
  29.  
  30. The DLLSERVE sample begins with the car-related COM Objects of the
  31. previous COMOBJ lesson and refashions them into components. To do so
  32. requires little change to the COM objects themselves (COCar, COUtilityCar,
  33. and COCruiseCar). But to envelop them as components, this lesson
  34. introduces new facilities to house them in an in-process DLL COM server.
  35. These facilities include class factories for each component and a
  36. CarSample utility component that allows clients to see logged behavior in
  37. the server itself.
  38.  
  39. The DLL server provides the following components: Car, UtilityCar,
  40. CruiseCar, and CarSample.
  41.  
  42. In the series of COM tutorial code samples, DLLSERVE works with the
  43. DLLCLIEN code sample to illustrate DLLSERVE's COM server facilities for
  44. creating components that can be used by an EXE client and the subsequent
  45. manipulation of those components by DLLCLIEN.EXE.
  46.  
  47. For functional descriptions and a tutorial code tour of DLLSERVE, see the
  48. Code Tour section in DLLSERVE.HTM. For details on setting up the
  49. programmatic usage of DLLSERVE, see the Usage section in DLLSERVE.HTM. To
  50. read DLLSERVE.HTM, run TUTORIAL.EXE in the main tutorial directory and
  51. click the DLLSERVE lesson in the table of lessons. You can also achieve
  52. the same thing by clicking the DLLSERVE.HTM file after locating the main
  53. tutorial directory in the Windows Explorer. See also DLLCLIEN.HTM in the
  54. main tutorial directory for more details on the DLLCLIEN client
  55. application and how it works with DLLSERVE.DLL.
  56.  
  57. You must build DLLSERVE.DLL before building or running DLLCLIEN.
  58. DLLSERVE's makefile automatically registers DLLSERVE's components in the
  59. registry. These components must be registered before DLLSERVE is available
  60. to outside COM clients as a server for those components. This registration
  61. is done using the REGISTER.EXE utility built in the previous REGISTER
  62. lesson. To build or run DLLSERVE, you should build the REGISTER code
  63. sample first.
  64.  
  65. For details on setting up your system to build and test the code samples
  66. in this COM Tutorial series, see TUTORIAL.HTM. The supplied MAKEFILE is
  67. Microsoft NMAKE-compatible. To create a debug build, issue the NMAKE
  68. command in the Command Prompt window.
  69.  
  70. Usage
  71. -----
  72.  
  73. DLLSERVE is a DLL that is meant to be used primarily as a COM server.
  74. Though it can be implicitly loaded by linking to its associated .LIB file,
  75. it is normally used after an explicit LoadLibrary call (usually from COM's
  76. CoGetClassObject function). Servers like DLLSERVE are registered in the
  77. registry. To use DLLSERVE in a COM client program, a client does not need
  78. to include DLLSERVE.H or link to DLLSERVE.LIB. A COM client of DLLSERVE
  79. obtains access solely through its components' CLSIDs and COM services. For
  80. DLLSERVE, those CLSIDs are CLSID_DllCar, CLSID_DllUtilityCar,
  81. CLSID_DllCruiseCar, and CLSID_DllCarSample. The DLLCLIEN lesson shows how
  82. this is done.
  83.  
  84. The makefile that builds this sample automatically registers the server in
  85. the registry. You can manually initiate its self-registration by issuing
  86. the following command at the command prompt in the DLLSERVE directory:
  87.  
  88.   nmake register
  89.  
  90. You can also directly invoke the REGISTER.EXE command at the command prompt
  91. while in the DLLSERVE directory.
  92.  
  93.   ..\register\register.exe dllserve.dll
  94.  
  95. These registration commands require a prior build of the REGISTER sample
  96. in this series, as well as a prior build of DLLSERVE.DLL.
  97.  
  98. In this series, the makefiles use the REGISTER.EXE utility from the
  99. REGISTER sample. Recent releases of the Win32 Platform SDK and Visual C++
  100. include a utility, REGSVR32.EXE, which can be used in a similar fashion to
  101. register in-process servers and marshaling DLLs.
  102.  
  103.  
  104. FILES
  105. =====
  106.  
  107. Files         Description
  108.  
  109. DLLSERVE.TXT  This file.
  110. MAKEFILE      The generic makefile for building the DLLSERVE.DLL
  111.               code sample of this tutorial lesson.
  112. DLLSERVE.H    The include file for declaring as imported or defining as
  113.               exported the service functions in DLLSERVE.DLL.
  114. DLLSERVE.CPP  The main implementation file for DLLSERVE.DLL. Has DllMain
  115.               and the COM server functions (for example, DllGetClassObject).
  116. DLLSERVE.DEF  The module definition file. Exports server housing functions.
  117. DLLSERVE.RC   The DLL resource definition file for the executable.
  118. DLLSERVE.ICO  The icon resource for the executable.
  119. SERVER.H      The include file for the server control C++ object. Also has
  120.               resource identifiers for resources stored inside DLLSERVE.DLL
  121.               and other external declarations that are used internally
  122.               within the modules of DLLSERVE.DLL.
  123. SERVER.CPP    The implementation file for the server control object.
  124. FACTORY.H     The include file for the server's class factory COM objects.
  125. FACTORY.CPP   The implementation file for the server's class factories.
  126. CAR.H         The include file for the COCar COM object class.
  127. CAR.CPP       The implementation file for the COCar COM object class.
  128. UTILCAR.H     The include file for the COUtililtyCar COM object class.
  129. UTILCAR.CPP   The implementation file for the COUtilityCar COM object class.
  130. CRUCAR.H      The include file for the COCruiseCar COM object class.
  131. CRUCAR.CPP    The implementation file for the COCruiseCar COM object class.
  132. SAMPLE.H      The include file for the COCarSample COM object class.
  133. SAMPLE.CPP    The implementation file for the COCarSample COM object class.
  134.