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

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