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.

67 lines
2.0 KiB

  1. /*****************************************************************************
  2. *
  3. * ftpglob.h - HGLOBAL babysitting
  4. *
  5. * Included from ftpview.h
  6. *
  7. *****************************************************************************/
  8. #ifndef _FTPGLOB_H
  9. #define _FTPGLOB_H
  10. /*****************************************************************************
  11. *
  12. * This is the generic IUnknown wrapper that GlobalFree's its
  13. * charge when released.
  14. *
  15. *****************************************************************************/
  16. /*****************************************************************************
  17. *
  18. * CFtpGlob
  19. *
  20. * CFtpGlob is used as the punkForRelease when we hand a shared HGLOBAL
  21. * out to somebody else. We can't simply use the DataObject itself,
  22. * because that would result in havoc if the DataObject itself decided
  23. * to free the HGLOBAL while there were still outstanding references to it.
  24. *
  25. * It's also used when we need a refcounted string. Just put the
  26. * string into the hglob and have fun.
  27. *
  28. *****************************************************************************/
  29. class CFtpGlob : public IUnknown
  30. {
  31. public:
  32. //////////////////////////////////////////////////////
  33. // Public Interfaces
  34. //////////////////////////////////////////////////////
  35. // *** IUnknown ***
  36. virtual STDMETHODIMP_(ULONG) AddRef(void);
  37. virtual STDMETHODIMP_(ULONG) Release(void);
  38. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  39. public:
  40. CFtpGlob();
  41. ~CFtpGlob(void);
  42. // Public Member Functions
  43. HRESULT SetHGlob(HGLOBAL hglob) {m_hglob = hglob; return S_OK;};
  44. HGLOBAL GetHGlob(void) {return m_hglob;};
  45. LPCTSTR GetHGlobAsTCHAR(void) {return (LPCTSTR) m_hglob;};
  46. // Friend Functions
  47. friend IUnknown * CFtpGlob_Create(HGLOBAL hglob);
  48. friend CFtpGlob * CFtpGlob_CreateStr(LPCTSTR pszStr);
  49. protected:
  50. // Private Member Variables
  51. int m_cRef;
  52. HGLOBAL m_hglob; // The HGLOBAL we are babysitting
  53. };
  54. #endif // _FTPGLOB_H