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.

65 lines
1.9 KiB

  1. /*++
  2. Copyright (C) 2001 Microsoft Corporation
  3. Module Name: ErrorObj
  4. Abstract: IErrorInfo support for the standard consumers
  5. History: 07/11/2001 - creation, HHance.
  6. --*/
  7. #ifndef STDCONS_ERROBJ_COMPILED
  8. #define STDCONS_ERROBJ_COMPILED
  9. #include <wbemidl.h>
  10. #include <sync.h>
  11. // class to build an IErrorInfo (Acutally an IWbemClassObject for our purposes)
  12. // used by the standard consumers to report errors in execution
  13. // we'll keep a single global object around, lifetime managed by addref & release
  14. // instanciation & access is via GetErrorObj()
  15. class ErrorObj
  16. {
  17. public:
  18. // so we can manage our component's lifetimes in the wunnerful world of COM, etc...
  19. // returns addref'd error object
  20. static ErrorObj* GetErrorObj();
  21. // does the real work, creates the object, populates it, sends it off.
  22. // arguments map to __ExtendedStatus class.
  23. // void func - what are y'gonna do if you can't report an error? Report an error?
  24. // bFormat - will attempt to use FormatError to fill in the description if NULL.
  25. void ReportError(const WCHAR* operation, const WCHAR* parameterInfo, const WCHAR* description, UINT statusCode, bool bFormat);
  26. ULONG AddRef();
  27. ULONG Release();
  28. // Do not create one of these!
  29. // Use GetErrorObj. Thou Hast Been Warned...
  30. ErrorObj() : m_pErrorObject(NULL), m_lRef(0) { };
  31. // com objects are taken care of by Release()
  32. ~ErrorObj() { };
  33. protected:
  34. // must be called prior to SetError (if you expect it to succeed, anyway...)
  35. IWbemServices* GetMeANamespace();
  36. // refcount, when it goes to zero, we release our COM objects
  37. ULONG m_lRef;
  38. // error object object
  39. IWbemClassObject* m_pErrorObject;
  40. // protection for our IWbemXXX pointers.
  41. CCritSec m_cs;
  42. // spawn off an object to be populated
  43. IWbemClassObject* GetObj();
  44. };
  45. #endif // STDCONS_ERROBJ_COMPILED