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.

111 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 "denpre.h"
  11. #pragma hdrstop
  12. #include "gip.h"
  13. #include "memchk.h"
  14. /*===================================================================
  15. Globals
  16. ===================================================================*/
  17. CGlobalInterfaceAPI g_GIPAPI;
  18. /*===================================================================
  19. C G l o b a l I n t e r f a c e A P I
  20. ===================================================================*/
  21. /*===================================================================
  22. CGlobalInterfaceAPI::CGlobalInterfaceAPI
  23. CGlobalInterfaceAPI constructor
  24. Parameters:
  25. Returns:
  26. ===================================================================*/
  27. CGlobalInterfaceAPI::CGlobalInterfaceAPI()
  28. : m_fInited(FALSE), m_pGIT(NULL)
  29. {
  30. }
  31. /*===================================================================
  32. CGlobalInterfaceAPI::~CGlobalInterfaceAPI
  33. CGlobalInterfaceAPI destructor
  34. Parameters:
  35. Returns:
  36. ===================================================================*/
  37. CGlobalInterfaceAPI::~CGlobalInterfaceAPI()
  38. {
  39. UnInit();
  40. }
  41. /*===================================================================
  42. CGlobalInterfaceAPI::Init
  43. Creates instance of GlobalInterfaceTable
  44. Parameters:
  45. Returns:
  46. HRESULT
  47. ===================================================================*/
  48. HRESULT CGlobalInterfaceAPI::Init()
  49. {
  50. 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 (S_OK)
  71. ===================================================================*/
  72. HRESULT CGlobalInterfaceAPI::UnInit()
  73. {
  74. if (m_pGIT)
  75. {
  76. m_pGIT->Release();
  77. m_pGIT = NULL;
  78. }
  79. m_fInited = FALSE;
  80. return S_OK;
  81. }