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.

92 lines
2.1 KiB

  1. /*++
  2. Copyright (C) 1999-2001 Microsoft Corporation
  3. Module Name:
  4. ADAPUTIL.CPP
  5. Abstract:
  6. History:
  7. --*/
  8. #include "precomp.h"
  9. #include <stdio.h>
  10. #include <wtypes.h>
  11. #include <oleauto.h>
  12. #include <winmgmtr.h>
  13. #include "AdapUtil.h"
  14. extern HANDLE g_hAbort;
  15. HRESULT CAdapUtility::NTLogEvent( DWORD dwEventType,
  16. DWORD dwEventID,
  17. CInsertionString c1,
  18. CInsertionString c2,
  19. CInsertionString c3,
  20. CInsertionString c4,
  21. CInsertionString c5,
  22. CInsertionString c6,
  23. CInsertionString c7,
  24. CInsertionString c8,
  25. CInsertionString c9,
  26. CInsertionString c10 )
  27. {
  28. HRESULT hr = WBEM_E_FAILED;
  29. CInsertionString ci[10];
  30. CEventLog el;
  31. // Also, during debug builds, we will BEEP for a second when we have decided to generate an
  32. // event
  33. #ifdef _DEBUG
  34. MessageBeep( 0xFFFFFFFF );
  35. #endif
  36. if ( el.Open() )
  37. {
  38. if ( el.Report( dwEventType, dwEventID, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10 ) )
  39. {
  40. hr = WBEM_NO_ERROR;
  41. }
  42. }
  43. el.Close();
  44. return hr;
  45. }
  46. HRESULT CAdapUtility::AdapTrace( const char* format, ... )
  47. {
  48. HRESULT hr = WBEM_E_FAILED;
  49. va_list list;
  50. va_start( list, format );
  51. if ( 0 != DebugTrace(LOG_WMIADAP, format, list ) )
  52. {
  53. hr = WBEM_NO_ERROR;
  54. }
  55. va_end( list );
  56. return hr;
  57. }
  58. HRESULT CAdapUtility::Abort( WString wstrClassName, CAdapPerfLib* pPerfLib, HRESULT hRes )
  59. {
  60. HRESULT hr = WBEM_NO_ERROR;
  61. if ( NULL != g_hAbort )
  62. SetEvent( g_hAbort );
  63. // Log an event
  64. CAdapUtility::NTLogEvent( EVENTLOG_WARNING_TYPE,
  65. WBEM_MC_ADAP_GENERAL_OBJECT_FAILURE,
  66. (LPWSTR) wstrClassName,
  67. pPerfLib->GetLibraryName(),
  68. CHex( hRes ) );
  69. return hr;
  70. }