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.

124 lines
3.3 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // Notifications.cpp
  7. //
  8. // Abstract:
  9. // Implementation of functions that send out notifications.
  10. //
  11. // Author:
  12. // Vijayendra Vasu (vvasu) 17-AUG-2000
  13. //
  14. // Revision History:
  15. // None.
  16. //
  17. /////////////////////////////////////////////////////////////////////////////
  18. #define UNICODE 1
  19. #define _UNICODE 1
  20. /////////////////////////////////////////////////////////////////////////////
  21. // Include files
  22. /////////////////////////////////////////////////////////////////////////////
  23. #include <objbase.h>
  24. #include <ClusCfgGuids.h>
  25. #include <ClusCfgServer.h>
  26. #include "clusrtl.h"
  27. /////////////////////////////////////////////////////////////////////////////
  28. //++
  29. //
  30. // ClRtlInitiateStartupNotification()
  31. //
  32. // Routine Description:
  33. // Initiate operations that inform interested parties that the cluster
  34. // service is starting up.
  35. //
  36. // Arguments:
  37. // None.
  38. //
  39. // Return Value:
  40. // S_OK
  41. // If the notification process was successfully initiated
  42. //
  43. // Other HRESULTS
  44. // In case of error
  45. //
  46. //--
  47. /////////////////////////////////////////////////////////////////////////////
  48. HRESULT ClRtlInitiateStartupNotification( void )
  49. {
  50. HRESULT hr = S_OK;
  51. IClusCfgStartupNotify * pccsnNotify = NULL;
  52. ICallFactory * pcfCallFactory = NULL;
  53. AsyncIClusCfgStartupNotify * paccsnAsyncNotify = NULL;
  54. // Initialize COM
  55. CoInitializeEx( NULL, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE );
  56. do
  57. {
  58. hr = CoCreateInstance(
  59. CLSID_ClusCfgStartupNotify
  60. , NULL
  61. , CLSCTX_LOCAL_SERVER
  62. , __uuidof( pccsnNotify )
  63. , reinterpret_cast< void ** >( &pccsnNotify )
  64. );
  65. if ( FAILED( hr ) )
  66. {
  67. break;
  68. } // if: we could not get a pointer to synchronous notification interface
  69. hr = pccsnNotify->QueryInterface( __uuidof( pcfCallFactory ), reinterpret_cast< void ** >( &pcfCallFactory ) );
  70. if ( FAILED( hr ) )
  71. {
  72. break;
  73. } // if: we could not get a pointer to the call factory interface
  74. hr = pcfCallFactory->CreateCall(
  75. __uuidof( paccsnAsyncNotify )
  76. , NULL
  77. , __uuidof( paccsnAsyncNotify )
  78. , reinterpret_cast< IUnknown ** >( &paccsnAsyncNotify )
  79. );
  80. if ( FAILED( hr ) )
  81. {
  82. break;
  83. } // if: we could not get a pointer to the asynchronous notification interface
  84. hr = paccsnAsyncNotify->Begin_SendNotifications();
  85. }
  86. while( false ); // dummy do-while loop to avoid gotos
  87. //
  88. // Free acquired resources
  89. //
  90. if ( pccsnNotify != NULL )
  91. {
  92. pccsnNotify->Release();
  93. } // if: we had obtained a pointer to the synchronous notification interface
  94. if ( pcfCallFactory != NULL )
  95. {
  96. pcfCallFactory->Release();
  97. } // if: we had obtained a pointer to the call factory interface
  98. if ( paccsnAsyncNotify != NULL )
  99. {
  100. paccsnAsyncNotify->Release();
  101. } // if: we had obtained a pointer to the asynchronous notification interface
  102. CoUninitialize();
  103. return hr;
  104. } //*** ClRtlInitiateStartupNotification()