home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / atl / opengl / opengl.cpp < prev    next >
C/C++ Source or Header  |  1998-03-26  |  3KB  |  89 lines

  1. // OpenGL.cpp : Implementation of DLL Exports.
  2. //
  3. // This is a part of the Active Template Library.
  4. // Copyright (C) 1996-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Active Template Library Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Active Template Library product.
  12.  
  13. // You will need the NT SUR Beta 2 SDK or VC 4.2 in order to build this
  14. // project.  This is because you will need MIDL 3.00.15 or higher and new
  15. // headers and libs.  If you have VC 4.2 installed, then everything should
  16. // already be configured correctly.
  17.  
  18. // Note: Proxy/Stub Information
  19. //      To build a separate proxy/stub DLL,
  20. //      run nmake -f OpenGLps.mak in the project directory.
  21.  
  22. #include "stdafx.h"
  23. #include "resource.h"
  24. #include "initguid.h"
  25. #include "OpenGL.h"
  26. #include "OpenGLObj.h"
  27. #include <atlwin.cpp>
  28. #include <atlctl.cpp>
  29.  
  30. #define IID_DEFINED
  31. #include "OpenGL_i.c"
  32.  
  33.  
  34. CComModule _Module;
  35.  
  36. BEGIN_OBJECT_MAP(ObjectMap)
  37.     OBJECT_ENTRY(CLSID_COpenGLObj, COpenGLObj)
  38. END_OBJECT_MAP()
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // DLL Entry Point
  42.  
  43. extern "C"
  44. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  45. {
  46.     if (dwReason == DLL_PROCESS_ATTACH)
  47.     {
  48.         _Module.Init(ObjectMap, hInstance);
  49.         DisableThreadLibraryCalls(hInstance);
  50.     }
  51.     else if (dwReason == DLL_PROCESS_DETACH)
  52.         _Module.Term();
  53.     return TRUE;    // ok
  54. }
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57. // Used to determine whether the DLL can be unloaded by OLE
  58.  
  59. STDAPI DllCanUnloadNow(void)
  60. {
  61.     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  62. }
  63.  
  64. /////////////////////////////////////////////////////////////////////////////
  65. // Returns a class factory to create an object of the requested type
  66.  
  67. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  68. {
  69.     return _Module.GetClassObject(rclsid, riid, ppv);
  70. }
  71.  
  72. /////////////////////////////////////////////////////////////////////////////
  73. // DllRegisterServer - Adds entries to the system registry
  74.  
  75. STDAPI DllRegisterServer(void)
  76. {
  77.     // registers object, typelib and all interfaces in typelib
  78.     return _Module.RegisterServer(TRUE);
  79. }
  80.  
  81. /////////////////////////////////////////////////////////////////////////////
  82. // DllUnregisterServer - Removes entries from the system registry
  83.  
  84. STDAPI DllUnregisterServer(void)
  85. {
  86.     _Module.UnregisterServer();
  87.     return S_OK;
  88. }
  89.