Source code of Windows XP (NT5)
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.

97 lines
2.5 KiB

  1. // This is a part of the Microsoft Management Console.
  2. // Copyright 1995 - 1997 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Management Console and related
  7. // electronic documentation provided with the interfaces.
  8. // You will need the NT SUR Beta 2 SDK or VC 4.2 in order to build this
  9. // project. This is because you will need MIDL 3.00.15 or higher and new
  10. // headers and libs. If you have VC 4.2 installed, then everything should
  11. // already be configured correctly.
  12. // Note: Proxy/Stub Information
  13. // To build a separate proxy/stub DLL,
  14. // run nmake -f Snapinps.mak in the project directory.
  15. #include "stdafx.h"
  16. #include "resource.h"
  17. #include "initguid.h"
  18. #include "Service.h"
  19. #include "CSnapin.h"
  20. CComModule _Module;
  21. BEGIN_OBJECT_MAP(ObjectMap)
  22. OBJECT_ENTRY(CLSID_Snapin, CComponentDataPrimaryImpl)
  23. OBJECT_ENTRY(CLSID_Extension, CComponentDataExtensionImpl)
  24. OBJECT_ENTRY(CLSID_About, CSnapinAboutImpl)
  25. END_OBJECT_MAP()
  26. #ifdef _DEBUG
  27. #define new DEBUG_NEW
  28. #undef THIS_FILE
  29. static char THIS_FILE[] = __FILE__;
  30. #endif
  31. class CSnapinApp : public CWinApp
  32. {
  33. public:
  34. virtual BOOL InitInstance();
  35. virtual int ExitInstance();
  36. };
  37. CSnapinApp theApp;
  38. BOOL CSnapinApp::InitInstance()
  39. {
  40. _Module.Init(ObjectMap, m_hInstance);
  41. return CWinApp::InitInstance();
  42. }
  43. int CSnapinApp::ExitInstance()
  44. {
  45. _Module.Term();
  46. DEBUG_VERIFY_INSTANCE_COUNT(CSnapin);
  47. DEBUG_VERIFY_INSTANCE_COUNT(CComponentDataImpl);
  48. return CWinApp::ExitInstance();
  49. }
  50. /////////////////////////////////////////////////////////////////////////////
  51. // Used to determine whether the DLL can be unloaded by OLE
  52. STDAPI DllCanUnloadNow(void)
  53. {
  54. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  55. return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
  56. }
  57. /////////////////////////////////////////////////////////////////////////////
  58. // Returns a class factory to create an object of the requested type
  59. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  60. {
  61. return _Module.GetClassObject(rclsid, riid, ppv);
  62. }
  63. /////////////////////////////////////////////////////////////////////////////
  64. // DllRegisterServer - Adds entries to the system registry
  65. STDAPI DllRegisterServer(void)
  66. {
  67. // registers object, typelib and all interfaces in typelib
  68. return _Module.RegisterServer(FALSE);
  69. }
  70. /////////////////////////////////////////////////////////////////////////////
  71. // DllUnregisterServer - Removes entries from the system registry
  72. STDAPI DllUnregisterServer(void)
  73. {
  74. _Module.UnregisterServer();
  75. return S_OK;
  76. }