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.

81 lines
1.4 KiB

  1. #include <atlinc.h>
  2. // just need this one for TYPE_ defines
  3. #include <itpropl.h>
  4. #include "prop.h"
  5. #include <mvopsys.h>
  6. #include <_mvutil.h>
  7. // Inititialization of static members
  8. int CIntProperty::m_cRefCount = 0;
  9. LPVOID CIntProperty::m_pMemPool = NULL;
  10. CIntProperty::CIntProperty()
  11. {
  12. // ref count is 0 so allocate pool
  13. if (0 == m_cRefCount)
  14. {
  15. m_pMemPool = BlockInitiate((DWORD)65500, 0, 0, 0);
  16. }
  17. m_cRefCount++;
  18. }
  19. CIntProperty::~CIntProperty()
  20. {
  21. m_cRefCount--;
  22. // ref count has gone to 0, so deallocate pool
  23. if (0 == m_cRefCount)
  24. {
  25. BlockFree(m_pMemPool);
  26. m_pMemPool = NULL;
  27. }
  28. }
  29. STDMETHODIMP CIntProperty::SetProp(LPCWSTR lpszwString)
  30. {
  31. // remember a Unicode char is 2 bytes... We may not really need to
  32. // store this info.
  33. m_dwType = TYPE_STRING;
  34. if (lpszwString)
  35. {
  36. m_cbSize = (DWORD) (WSTRLEN(lpszwString) + 1) * sizeof(WCHAR);
  37. // copy data into pool
  38. if (NULL == (m_lpszwString = (LPWSTR) BlockCopy(m_pMemPool, (LPBYTE) lpszwString, m_cbSize, 0) ))
  39. return E_OUTOFMEMORY;
  40. }
  41. else
  42. {
  43. m_lpszwString = NULL;
  44. m_cbSize = 0;
  45. }
  46. return S_OK;
  47. }
  48. STDMETHODIMP CIntProperty::SetProp(LPVOID lpvData, DWORD cbBufSize)
  49. {
  50. m_cbSize = cbBufSize;
  51. m_dwType = TYPE_POINTER;
  52. // copy data into pool
  53. if (NULL == (m_lpvData = BlockCopy(m_pMemPool, (LPBYTE)lpvData, m_cbSize, 0) ))
  54. return E_OUTOFMEMORY;
  55. return S_OK;
  56. }