home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / MS_VC.50 / VC / ATL / SRC / ATL.CPP next >
Encoding:
C/C++ Source or Header  |  1996-12-17  |  2.2 KB  |  78 lines

  1. // atl.cpp : Implementation of DLL Exports.
  2.  
  3. // You will need the NT SUR Beta 2 SDK or VC 4.2 or higher in order to build
  4. // this 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 atlps.mak in the project directory.
  11.  
  12. #include "stdafx.h"
  13. #include "resource.h"
  14. #include "atl.h"
  15.  
  16. #include "atl_i.c"
  17. #include "RegObj.h"
  18.  
  19.  
  20. CComModule _Module;
  21.  
  22. BEGIN_OBJECT_MAP(ObjectMap)
  23.     OBJECT_ENTRY(CLSID_Registrar, CDLLRegObject)
  24. END_OBJECT_MAP()
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // DLL Entry Point
  28.  
  29. extern "C"
  30. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  31. {
  32.     if (dwReason == DLL_PROCESS_ATTACH)
  33.     {
  34.         _Module.Init(ObjectMap, hInstance);
  35.         DisableThreadLibraryCalls(hInstance);
  36.     }
  37.     else if (dwReason == DLL_PROCESS_DETACH)
  38.         _Module.Term();
  39.     return TRUE;    // ok
  40. }
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // Used to determine whether the DLL can be unloaded by OLE
  44.  
  45. STDAPI DllCanUnloadNow(void)
  46. {
  47.     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  48. }
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // Returns a class factory to create an object of the requested type
  52.  
  53. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  54. {
  55.     return _Module.GetClassObject(rclsid, riid, ppv);
  56. }
  57.  
  58. /////////////////////////////////////////////////////////////////////////////
  59. // DllRegisterServer - Adds entries to the system registry
  60.  
  61. STDAPI DllRegisterServer(void)
  62. {
  63.     // registers object, typelib and all interfaces in typelib
  64.     return _Module.RegisterServer(FALSE);
  65. }
  66.  
  67. /////////////////////////////////////////////////////////////////////////////
  68. // DllUnregisterServer - Removes entries from the system registry
  69.  
  70. STDAPI DllUnregisterServer(void)
  71. {
  72.     _Module.UnregisterServer();
  73. #if _WIN32_WINNT >= 0x0400
  74.     UnRegisterTypeLib(LIBID_ATLLib, 1, 0, LOCALE_USER_DEFAULT, SYS_WIN32);
  75. #endif
  76.     return S_OK;
  77. }
  78.