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.

112 lines
2.6 KiB

  1. /*===================================================================
  2. Microsoft Denali
  3. Microsoft Confidential.
  4. Copyright 1997 Microsoft Corporation. All Rights Reserved.
  5. Component: Global Interface Pointer API support
  6. File: Gip.cpp
  7. Owner: DmitryR
  8. This is the GIP source file.
  9. ===================================================================*/
  10. #include "w3p.hxx"
  11. #include "gip.h"
  12. /*===================================================================
  13. Globals
  14. ===================================================================*/
  15. CGlobalInterfaceAPI g_GIPAPI;
  16. /*===================================================================
  17. C G l o b a l I n t e r f a c e A P I
  18. ===================================================================*/
  19. /*===================================================================
  20. CGlobalInterfaceAPI::CGlobalInterfaceAPI
  21. CGlobalInterfaceAPI constructor
  22. Parameters:
  23. Returns:
  24. ===================================================================*/
  25. CGlobalInterfaceAPI::CGlobalInterfaceAPI()
  26. : m_fInited(FALSE), m_pGIT(NULL)
  27. {
  28. }
  29. /*===================================================================
  30. CGlobalInterfaceAPI::~CGlobalInterfaceAPI
  31. CGlobalInterfaceAPI destructor
  32. Parameters:
  33. Returns:
  34. ===================================================================*/
  35. CGlobalInterfaceAPI::~CGlobalInterfaceAPI()
  36. {
  37. UnInit();
  38. }
  39. /*===================================================================
  40. CGlobalInterfaceAPI::Init
  41. Creates instance of GlobalInterfaceTable
  42. Parameters:
  43. Returns:
  44. HRESULT
  45. ===================================================================*/
  46. HRESULT CGlobalInterfaceAPI::Init()
  47. {
  48. IF_DEBUG( SERVICE_CTRL )
  49. DBGPRINTF(( DBG_CONTEXT, "CGlobalInterfaceAPI::Init()\n"));
  50. DBG_ASSERT(!m_fInited); // don't init twice
  51. HRESULT hr = CoCreateInstance
  52. (
  53. CLSID_StdGlobalInterfaceTable,
  54. NULL,
  55. CLSCTX_INPROC_SERVER,
  56. IID_IGlobalInterfaceTable,
  57. (void **)&m_pGIT
  58. );
  59. if (SUCCEEDED(hr))
  60. m_fInited = TRUE;
  61. else
  62. m_pGIT = NULL;
  63. return hr;
  64. }
  65. /*===================================================================
  66. CGlobalInterfaceAPI::UnInit
  67. Releases instance of GlobalInterfaceTable
  68. Parameters:
  69. Returns:
  70. HRESULT (NOERROR)
  71. ===================================================================*/
  72. HRESULT CGlobalInterfaceAPI::UnInit()
  73. {
  74. IF_DEBUG( SERVICE_CTRL )
  75. DBGPRINTF(( DBG_CONTEXT, "CGlobalInterfaceAPI::UnInit()\n"));
  76. if (m_pGIT)
  77. {
  78. m_pGIT->Release();
  79. m_pGIT = NULL;
  80. }
  81. m_fInited = FALSE;
  82. return NOERROR;
  83. }