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.

50 lines
1.2 KiB

  1. // Copyright (c) 1997-1999 Microsoft Corporation
  2. class CUnsecWrap
  3. {
  4. protected:
  5. IWbemObjectSink* m_pSink;
  6. IWbemObjectSink* m_pWrapper;
  7. static IUnsecuredApartment* mstatic_pApartment;
  8. protected:
  9. static void Init()
  10. {
  11. if(mstatic_pApartment == NULL)
  12. {
  13. HRESULT hres = CoCreateInstance(CLSID_UnsecuredApartment, NULL,
  14. CLSCTX_ALL,
  15. IID_IUnsecuredApartment,
  16. (void**)&mstatic_pApartment);
  17. }
  18. }
  19. public:
  20. CUnsecWrap(IWbemObjectSink* pSink) :
  21. m_pSink(pSink),
  22. m_pWrapper(NULL)
  23. {
  24. m_pSink->AddRef();
  25. Init();
  26. }
  27. ~CUnsecWrap()
  28. {
  29. m_pSink->Release();
  30. if(m_pWrapper)
  31. m_pWrapper->Release();
  32. }
  33. operator IWbemObjectSink*()
  34. {
  35. if(m_pWrapper)
  36. return m_pWrapper;
  37. IUnknown* pUnk;
  38. mstatic_pApartment->CreateObjectStub(m_pSink, &pUnk);
  39. pUnk->QueryInterface(IID_IWbemObjectSink, (void**)&m_pWrapper);
  40. pUnk->Release();
  41. return m_pWrapper;
  42. }
  43. };
  44. IUnsecuredApartment* CUnsecWrap::mstatic_pApartment = NULL;