home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / addins / pipe / pipe.cpp < prev    next >
C/C++ Source or Header  |  1998-04-02  |  2KB  |  81 lines

  1. // pipe.cpp : Implementation of DLL Exports.
  2.  
  3.  
  4. // Note: Proxy/Stub Information
  5. //        To build a separate proxy/stub DLL, 
  6. //        run nmake -f pipeps.mk in the project directory.
  7.  
  8. #include "stdafx.h"
  9. #include "resource.h"
  10. #include "initguid.h"
  11. #include "pipe.h"
  12.  
  13. #include "pipe_i.c"
  14. #include <initguid.h>
  15. #include "PipeIt.h"
  16.  
  17.  
  18. CComModule _Module;
  19.  
  20. BEGIN_OBJECT_MAP(ObjectMap)
  21.     OBJECT_ENTRY(CLSID_PipeIt, CPipeIt)
  22. END_OBJECT_MAP()
  23.  
  24. class CPipeApp : public CWinApp
  25. {
  26. public:
  27.     virtual BOOL InitInstance();
  28.     virtual int ExitInstance();
  29. };
  30.  
  31. CPipeApp theApp;
  32.  
  33. BOOL CPipeApp::InitInstance()
  34. {
  35.     _Module.Init(ObjectMap, m_hInstance);
  36.     return CWinApp::InitInstance();
  37. }
  38.  
  39. int CPipeApp::ExitInstance()
  40. {
  41.     _Module.Term();
  42.     return CWinApp::ExitInstance();
  43. }
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // Used to determine whether the DLL can be unloaded by OLE
  47.  
  48. STDAPI DllCanUnloadNow(void)
  49. {
  50.     AFX_MANAGE_STATE(AfxGetStaticModuleState());
  51.     return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
  52. }
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // Returns a class factory to create an object of the requested type
  56.  
  57. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  58. {
  59.     return _Module.GetClassObject(rclsid, riid, ppv);
  60. }
  61.  
  62. /////////////////////////////////////////////////////////////////////////////
  63. // DllRegisterServer - Adds entries to the system registry
  64.  
  65. STDAPI DllRegisterServer(void)
  66. {
  67.     // registers object, typelib and all interfaces in typelib
  68.     return _Module.RegisterServer(TRUE);
  69. }
  70.  
  71. /////////////////////////////////////////////////////////////////////////////
  72. // DllUnregisterServer - Removes entries from the system registry
  73.  
  74. STDAPI DllUnregisterServer(void)
  75. {
  76.     _Module.UnregisterServer();
  77.     return S_OK;
  78. }
  79.  
  80.  
  81.