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 / conserve / conserve.txt < prev    next >
Text File  |  1997-08-05  |  6KB  |  124 lines

  1.  
  2. CONSERVE - Connectable COM objects in an in-process server
  3.  
  4.  
  5. SUMMARY
  6. =======
  7.  
  8. The CONSERVE sample shows how to construct a connectable COM object,
  9. COBall, in a thread-safe in-process server. To expose connectable object
  10. features, COBall implements the standard COM interface,
  11. IConnectionPointContainer. COBall also implements the custom interface,
  12. IBall, that was introduced in the FRESERVE sample.
  13.  
  14. The principal focus of CONSERVE is the connectable object support in
  15. COBall and how connected clients are notified of ball events. CONSERVE
  16. works with the CONCLIEN client code sample.
  17.  
  18. CONSERVE's COBall implements a virtual moving ball similar to the one
  19. coded in the FRESERVE sample. However, rather than FRESERVE's
  20. free-threaded COM object, CONSERVE houses COBall in an apartment model
  21. server. COBall defines the internal logic of a moving ball that exists
  22. within a specified two-dimensional bounding rectangle. COBall provides
  23. only a description of a ball. It is up to the client to create a graphical
  24. representation based on the data managed in COBall.
  25.  
  26. Clients move the virtual ball using its IBall interface. COBall's internal
  27. logic will bounce the ball when it collides with a boundary. The client
  28. can obtain the ball's current position, size, and color to permit display
  29. of the ball's moving image. The client can also use the connection
  30. facilities of COBall to receive notifications of ball bounce events. The
  31. CONCLIEN sample will use these connection facilities to produce various
  32. sounds when the ball bounces.
  33.  
  34. CONSERVE uses the CThreaded facility in APPUTIL for thread safety, as in
  35. the FRESERVE sample. COBall objects are derived from the CThreaded class
  36. and inherit its OwnThis and UnOwnThis methods. These methods allow only
  37. one thread at a time to have access to the CONSERVE server and to COBall
  38. objects managed by the server.
  39.  
  40. For functional descriptions and a tutorial code tour of CONSERVE, see the
  41. Code Tour section in CONSERVE.HTM. For details on setting up the
  42. programmatic usage of CONSERVE, see the Usage section in CONSERVE.HTM. To
  43. read CONSERVE.HTM, run TUTORIAL.EXE in the main tutorial directory and
  44. click the CONSERVE lesson in the table of lessons. You can also achieve
  45. the same thing by clicking the CONSERVE.HTM file after locating the main
  46. tutorial directory in the Windows Explorer. See also CONCLIEN.HTM in the
  47. main tutorial directory for more details on the CONCLIEN client
  48. application and how it works with CONSERVE.DLL. You must build
  49. CONSERVE.DLL before building or running CONCLIEN.
  50.  
  51. CONSERVE's makefile automatically registers the DllSndBall component in
  52. the registry. This component must be registered before CONSERVE is
  53. available to outside clients as a server for that component. This
  54. self-registration is done using the REGISTER.EXE utility built in the
  55. REGISTER lesson. To build or run CONSERVE, you should build the REGISTER
  56. code sample first.
  57.  
  58. For details on setting up your system to build and test the code samples
  59. in this COM Tutorial series, see TUTORIAL.HTM. The supplied MAKEFILE is
  60. Microsoft NMAKE-compatible. To create a debug build, issue the NMAKE
  61. command in the Command Prompt window.
  62.  
  63. Usage
  64. -----
  65.  
  66. To use CONSERVE, a client program does not need to include CONSERVE.H or
  67. link to CONSERVE.LIB. A client of CONSERVE obtains access solely through
  68. its object's CLSID and COM services. For CONSERVE, that CLSID is
  69. CLSID_DllSndBall (defined in BALLGUID.H in the \INC sibling directory).
  70. The CONCLIEN code sample shows how the client obtains this access.
  71.  
  72. CONSERVE is a DLL that is intended primarily as an in-process server.
  73. Although it can be implicitly loaded by linking to its associated .LIB
  74. file, it is normally used after an explicit LoadLibrary call, usually from
  75. within COM's CoGetClassObject function. CONSERVE is a self-registering
  76. in-process server.
  77.  
  78. The makefile that builds this sample automatically registers the server in
  79. the registry. You can manually initiate its self-registration by issuing
  80. the following command at the command prompt in the CONSERVE directory:
  81.  
  82.   nmake register
  83.  
  84. You can also directly invoke the REGISTER.EXE command at the command prompt
  85. while in the CONSERVE directory.
  86.  
  87.   ..\register\register.exe conserve.dll
  88.  
  89. These registration commands require a prior build of the REGISTER sample
  90. in this series, as well as a prior build of CONSERVE.DLL.
  91.  
  92. In this series, the makefiles use the REGISTER.EXE utility from the
  93. REGISTER sample. Recent releases of the Win32 Platform SDK and Visual C++
  94. include a utility, REGSVR32.EXE, which can be used in a similar fashion to
  95. register in-process servers and marshaling DLLs.
  96.  
  97.  
  98. FILES
  99. =====
  100.  
  101. Files         Description
  102.  
  103. CONSERVE.TXT  This file.
  104. MAKEFILE      The generic makefile for building the CONSERVE.DLL
  105.               code sample of this lesson.
  106. CONSERVE.H    The include file for declaring as imported or defining as
  107.               exported the service functions in CONSERVE.DLL.
  108. CONSERVE.CPP  The main implementation file for CONSERVE.DLL. Has DllMain
  109.               and the COM server functions (for example, DllGetClassObject).
  110. CONSERVE.DEF  The module definition file. Exports server housing functions.
  111. CONSERVE.RC   The DLL resource definition file for the executable.
  112. CONSERVE.ICO  The icon resource for the executable.
  113. SERVER.H      The include file for the server control C++ object.
  114. SERVER.CPP    The implementation file for the server control object.
  115. FACTORY.H     The include file for the server's class factory COM objects.
  116. FACTORY.CPP   The implementation file for the server's class factories.
  117. CONNECT.H     The include file for the connection point enumerator,
  118.               connection point, and connection enumerator classes.
  119. CONNECT.CPP   The implementation file for the connection point enumerator,
  120.               connection point, and connection enumerators objects.
  121. BALL.H        The include file for the COBall object class.
  122. BALL.CPP      The implementation file for the COBall object class
  123.               and the connection points.
  124.