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.

102 lines
2.7 KiB

  1. // RegwizCtrl.cpp : Implementation of DLL Exports.
  2. // Note: Proxy/Stub Information
  3. // To build a separate proxy/stub DLL,
  4. // run nmake -f RegwizCtrlps.mk in the project directory.
  5. #include "stdafx.h"
  6. #include "resource.h"
  7. #include "initguid.h"
  8. #include "RegwizCtrl.h"
  9. #include "RegwizCtrl_i.c"
  10. #include "CRWCtrl.h"
  11. #include "cathelp.h"
  12. CComModule _Module;
  13. BEGIN_OBJECT_MAP(ObjectMap)
  14. OBJECT_ENTRY(CLSID_RegWizCtrl, CRegWizCtrl)
  15. END_OBJECT_MAP()
  16. /////////////////////////////////////////////////////////////////////////////
  17. // DLL Entry Point
  18. extern "C"
  19. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  20. {
  21. if (dwReason == DLL_PROCESS_ATTACH)
  22. {
  23. _Module.Init(ObjectMap, hInstance);
  24. DisableThreadLibraryCalls(hInstance);
  25. }
  26. else if (dwReason == DLL_PROCESS_DETACH)
  27. _Module.Term();
  28. return TRUE; // ok
  29. }
  30. /////////////////////////////////////////////////////////////////////////////
  31. // Used to determine whether the DLL can be unloaded by OLE
  32. STDAPI DllCanUnloadNow(void)
  33. {
  34. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  35. }
  36. /////////////////////////////////////////////////////////////////////////////
  37. // Returns a class factory to create an object of the requested type
  38. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  39. {
  40. return _Module.GetClassObject(rclsid, riid, ppv);
  41. }
  42. /////////////////////////////////////////////////////////////////////////////
  43. // DllRegisterServer - Adds entries to the system registry
  44. STDAPI DllRegisterServer(void)
  45. {
  46. HRESULT hr;
  47. #ifdef _MERGE_PROXYSTUB
  48. HRESULT hRes = PrxDllRegisterServer();
  49. if (FAILED(hRes))
  50. return hRes;
  51. #endif
  52. // registers object, typelib and all interfaces in typelib
  53. if ( SUCCEEDED(hr =_Module.RegisterServer(TRUE)) &&
  54. SUCCEEDED(hr = CreateComponentCategory(CATID_SafeForScripting,
  55. L"Controls that are safely scriptable")) &&
  56. SUCCEEDED(hr = CreateComponentCategory(CATID_SafeForInitializing,
  57. L"Controls safely initializable from persistent data")) &&
  58. SUCCEEDED(hr = RegisterCLSIDInCategory(CLSID_RegWizCtrl,
  59. CATID_SafeForScripting)) )
  60. {
  61. hr = RegisterCLSIDInCategory(CLSID_RegWizCtrl, CATID_SafeForInitializing);
  62. }
  63. return hr;
  64. }
  65. /////////////////////////////////////////////////////////////////////////////
  66. // DllUnregisterServer - Removes entries from the system registry
  67. STDAPI DllUnregisterServer(void)
  68. {
  69. #ifdef _MERGE_PROXYSTUB
  70. PrxDllUnregisterServer();
  71. #endif
  72. _Module.UnregisterServer();
  73. // Remove CATID information.
  74. UnRegisterCLSIDInCategory(CLSID_RegWizCtrl, CATID_SafeForScripting);
  75. UnRegisterCLSIDInCategory(CLSID_RegWizCtrl, CATID_SafeForInitializing);
  76. return S_OK;
  77. }