Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
2.1 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1998, Microsoft Corp. All rights reserved.
  4. //
  5. // FILE
  6. //
  7. // iasads.cpp
  8. //
  9. // SYNOPSIS
  10. //
  11. // Implementation of DLL exports for an ATL in proc server.
  12. //
  13. // MODIFICATION HISTORY
  14. //
  15. // 02/20/1998 Original version.
  16. // 08/28/1998 Added Net and OleDB data stores.
  17. //
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #include <ias.h>
  20. #include <newop.cpp>
  21. CComModule _Module;
  22. #include <atlimpl.cpp>
  23. #include <adsstore.h>
  24. #include <netstore.h>
  25. BEGIN_OBJECT_MAP(ObjectMap)
  26. OBJECT_ENTRY(__uuidof(ADsDataStore), ADsDataStore)
  27. OBJECT_ENTRY(__uuidof(NetDataStore), NetDataStore)
  28. END_OBJECT_MAP()
  29. //////////
  30. // DLL Entry Point
  31. //////////
  32. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  33. {
  34. if (dwReason == DLL_PROCESS_ATTACH)
  35. {
  36. _Module.Init(ObjectMap, hInstance);
  37. DisableThreadLibraryCalls(hInstance);
  38. }
  39. else if (dwReason == DLL_PROCESS_DETACH)
  40. {
  41. _Module.Term();
  42. }
  43. return TRUE;
  44. }
  45. //////////
  46. // Used to determine whether the DLL can be unloaded by OLE
  47. //////////
  48. STDAPI DllCanUnloadNow(void)
  49. {
  50. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  51. }
  52. //////////
  53. // Returns a class factory to create an object of the requested type.
  54. //////////
  55. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  56. {
  57. return _Module.GetClassObject(rclsid, riid, ppv);
  58. }
  59. //////////
  60. // DllRegisterServer - Adds entries to the system registry
  61. //////////
  62. STDAPI DllRegisterServer(void)
  63. {
  64. return _Module.RegisterServer(TRUE);
  65. }
  66. //////////
  67. // DllUnregisterServer - Removes entries from the system registry
  68. //////////
  69. STDAPI DllUnregisterServer(void)
  70. {
  71. HRESULT hr = _Module.UnregisterServer();
  72. if (FAILED(hr)) return hr;
  73. hr = UnRegisterTypeLib(
  74. __uuidof(DataStore2Lib),
  75. 1,
  76. 0,
  77. MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL),
  78. SYS_WIN32
  79. );
  80. return hr;
  81. }