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

  1. // DrawCtl.cpp : Implementation of DLL Exports.
  2.  
  3. // You will need the NT SUR Beta 2 SDK or VC 4.2 in order to build this 
  4. // project.  This is because you will need MIDL 3.00.15 or higher and new
  5. // headers and libs.  If you have VC 4.2 installed, then everything should
  6. // already be configured correctly.
  7.  
  8. // Note: Proxy/Stub Information
  9. //      To build a separate proxy/stub DLL, 
  10. //      run nmake -f DrawCtlps.mak in the project directory.
  11.  
  12. #include "stdafx.h"
  13. #include "resource.h"
  14. #include "Draw.h"
  15.  
  16. CComModule _Module;
  17.  
  18. BEGIN_OBJECT_MAP(ObjectMap)
  19.     OBJECT_ENTRY(__uuidof(CoDrawCtl), CDrawCtl)
  20. END_OBJECT_MAP()
  21.  
  22. /////////////////////////////////////////////////////////////////////////////
  23. // DLL Entry Point
  24.  
  25. extern "C"
  26. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  27. {
  28.     if (dwReason == DLL_PROCESS_ATTACH)
  29.     {
  30.         _Module.Init(ObjectMap, hInstance);
  31.         DisableThreadLibraryCalls(hInstance);
  32.     }
  33.     else if (dwReason == DLL_PROCESS_DETACH)
  34.         _Module.Term();
  35.     return TRUE;    // ok
  36. }
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // Used to determine whether the DLL can be unloaded by OLE
  40.  
  41. STDAPI DllCanUnloadNow(void)
  42. {
  43.     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  44. }
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // Returns a class factory to create an object of the requested type
  48.  
  49. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  50. {
  51.     return _Module.GetClassObject(rclsid, riid, ppv);
  52. }
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // DllRegisterServer - Adds entries to the system registry
  56.  
  57. STDAPI DllRegisterServer(void)
  58. {
  59.     // registers object, typelib and all interfaces in typelib
  60.     return _Module.RegisterServer(TRUE);
  61. }
  62.  
  63. /////////////////////////////////////////////////////////////////////////////
  64. // DllUnregisterServer - Removes entries from the system registry
  65.  
  66. STDAPI DllUnregisterServer(void)
  67. {
  68.     _Module.UnregisterServer();
  69.     return S_OK;
  70. }
  71.  
  72.