1
0

browserWndRecord.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "main.h"
  2. #include "./browserWndRecord.h"
  3. OmBrowserWndRecord::OmBrowserWndRecord(HWND hwnd, const GUID *type)
  4. : ref(1)
  5. {
  6. this->hwnd = hwnd;
  7. this->type = (NULL != type) ? *type : GUID_NULL;
  8. }
  9. OmBrowserWndRecord::~OmBrowserWndRecord()
  10. {
  11. }
  12. HRESULT OmBrowserWndRecord::CreateInstance(HWND hwnd, const GUID *type, OmBrowserWndRecord **instance)
  13. {
  14. if (NULL == instance) return E_POINTER;
  15. if (NULL == hwnd)
  16. {
  17. *instance = NULL;
  18. return E_INVALIDARG;
  19. }
  20. *instance = new OmBrowserWndRecord(hwnd, type);
  21. if (NULL == *instance) return E_OUTOFMEMORY;
  22. return S_OK;
  23. }
  24. ULONG OmBrowserWndRecord::AddRef()
  25. {
  26. return InterlockedIncrement((LONG*)&ref);
  27. }
  28. ULONG OmBrowserWndRecord::Release()
  29. {
  30. if (0 == ref)
  31. return ref;
  32. LONG r = InterlockedDecrement((LONG*)&ref);
  33. if (0 == r)
  34. delete(this);
  35. return r;
  36. }
  37. HWND OmBrowserWndRecord::GetHwnd()
  38. {
  39. return hwnd;
  40. }
  41. HRESULT OmBrowserWndRecord::GetType(GUID *windowType)
  42. {
  43. if (NULL == windowType) return E_POINTER;
  44. *windowType = type;
  45. return S_OK;
  46. }
  47. HRESULT OmBrowserWndRecord::IsEqualType(const GUID *windowType)
  48. {
  49. if (NULL == windowType)
  50. {
  51. return (FALSE != IsEqualGUID(GUID_NULL, type)) ? S_OK : S_FALSE;
  52. }
  53. return (FALSE != IsEqualGUID(*windowType, type)) ? S_OK : S_FALSE;
  54. }