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.

94 lines
2.5 KiB

  1. // DSAdminExt.cpp : Implementation of DLL Exports.
  2. // Note: Proxy/Stub Information
  3. // To build a separate proxy/stub DLL,
  4. // run nmake -f DSAdminExtps.mk in the project directory.
  5. #include "stdafx.h"
  6. #include "resource.h"
  7. #include "globals.h"
  8. #include <initguid.h>
  9. #include "DSAdminExt.h"
  10. #include "DSAdminExt_i.c"
  11. #include "CMenuExt.h"
  12. #include "PropPageExt.h"
  13. CComModule _Module;
  14. // our globals
  15. HINSTANCE g_hinst;
  16. BEGIN_OBJECT_MAP(ObjectMap)
  17. OBJECT_ENTRY(CLSID_CMenuExt, CCMenuExt)
  18. OBJECT_ENTRY(CLSID_PropPageExt, CPropPageExt)
  19. END_OBJECT_MAP()
  20. /////////////////////////////////////////////////////////////////////////////
  21. // DLL Entry Point
  22. extern "C"
  23. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  24. {
  25. if (dwReason == DLL_PROCESS_ATTACH)
  26. {
  27. g_hinst = hInstance;
  28. _Module.Init(ObjectMap, hInstance, &LIBID_DSADMINEXTLib);
  29. DisableThreadLibraryCalls(hInstance);
  30. }
  31. else if (dwReason == DLL_PROCESS_DETACH)
  32. _Module.Term();
  33. return TRUE; // ok
  34. }
  35. /////////////////////////////////////////////////////////////////////////////
  36. // Used to determine whether the DLL can be unloaded by OLE
  37. STDAPI DllCanUnloadNow(void)
  38. {
  39. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  40. }
  41. /////////////////////////////////////////////////////////////////////////////
  42. // Returns a class factory to create an object of the requested type
  43. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  44. {
  45. return _Module.GetClassObject(rclsid, riid, ppv);
  46. }
  47. /////////////////////////////////////////////////////////////////////////////
  48. // DllRegisterServer - Adds entries to the system registry
  49. //
  50. // This sample modifies the ATL object wizard generated code to include
  51. // the registration of the snap-in as a context menu extension
  52. STDAPI DllRegisterServer(void)
  53. {
  54. HRESULT hr;
  55. _TCHAR szSnapInName[256];
  56. LoadString(g_hinst, IDS_SNAPINNAME, szSnapInName, sizeof(szSnapInName)/sizeof(szSnapInName[0]));
  57. // registers object, typelib and all interfaces in typelib
  58. hr = _Module.RegisterServer(TRUE);
  59. // place the registry information for the context menu extension
  60. if SUCCEEDED(hr)
  61. hr = RegisterSnapinAsExtension(szSnapInName);
  62. return hr;
  63. }
  64. /////////////////////////////////////////////////////////////////////////////
  65. // DllUnregisterServer - Removes entries from the system registry
  66. STDAPI DllUnregisterServer(void)
  67. {
  68. return _Module.UnregisterServer(TRUE);
  69. }