No Description
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.

BStrHolder.h 416B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include <OleAuto.h>
  3. struct BStrHolder
  4. {
  5. BStrHolder() :
  6. m_Str(NULL)
  7. {
  8. }
  9. BStrHolder(const wchar_t* str) :
  10. m_Str(SysAllocString(str))
  11. {
  12. }
  13. ~BStrHolder()
  14. {
  15. if (m_Str != NULL)
  16. SysFreeString(m_Str);
  17. }
  18. operator BSTR() const
  19. {
  20. return m_Str;
  21. }
  22. BSTR* operator&()
  23. {
  24. if (m_Str != NULL)
  25. {
  26. SysFreeString(m_Str);
  27. m_Str = NULL;
  28. }
  29. return &m_Str;
  30. }
  31. private:
  32. BSTR m_Str;
  33. };