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.

138 lines
2.5 KiB

  1. #include "priv.h"
  2. class CMyHlink : public IHlink
  3. {
  4. public:
  5. // *** IUnknown methods ***
  6. virtual HRESULT __stdcall QueryInterface(REFIID riid, LPVOID * ppvObj);
  7. virtual ULONG __stdcall AddRef(void) ;
  8. virtual ULONG __stdcall Release(void);
  9. // *** IOleWindow methods ***
  10. virtual HRESULT __stdcall SetHlinkSite(IHlinkSite *pihlSite);
  11. virtual HRESULT __stdcall GetHlinkSite(IHlinkSite **ppihlSite);
  12. virtual HRESULT __stdcall GetMonikerReference(
  13. IMoniker **ppimk,
  14. LPWSTR *ppwzLocation);
  15. virtual HRESULT __stdcall GetStringReference(LPWSTR *ppwzRefString);
  16. virtual HRESULT __stdcall GetFriendlyName(LPWSTR *ppwzFriendlyName);
  17. virtual HRESULT __stdcall Navigate(
  18. IHlinkFrame *pihlFrame,
  19. DWORD grfHLNF,
  20. LPBC pbc,
  21. DWORD dwbscCookie,
  22. IBindStatusCallback *pibsc,
  23. IHlinkBrowseContext *pihlbc);
  24. protected:
  25. CMyHlink();
  26. ~CMyHlink();
  27. UINT _cRef;
  28. IHlinkSite* _pihlSite;
  29. IMoniker* _pmk;
  30. TCHAR _szLocation[MAX_PATH];
  31. };
  32. CMyHlink::CMyHlink(IMoniker* pmk, LPCTSTR pszLocation, LPCSTR pszFriedlyName)
  33. : _cRef(1), _pihlSite(NULL), _pmk(pmk)
  34. {
  35. if (_pmk) {
  36. _pmk->AddRef();
  37. }
  38. if (pszLocation) {
  39. lstrcpy(_szLocation, pszLocation);
  40. } else {
  41. _szLocation[0] = '\0';
  42. }
  43. }
  44. CMyHlink::~CMyHlink()
  45. {
  46. if (_pmk) {
  47. _pmk->Release();
  48. }
  49. if (_pihlSite) {
  50. _pihlSite->Release();
  51. }
  52. }
  53. HRESULT CMyHlink::QueryInterface(REFIID riid, LPVOID * ppvObj)
  54. {
  55. }
  56. ULONG CMyHlink::AddRef(void)
  57. {
  58. return ++_cRef;
  59. }
  60. ULONG CMyHlink::Release(void)
  61. {
  62. if (--_cRef > 0) {
  63. return _cRef;
  64. }
  65. delete this;
  66. return 0;
  67. }
  68. HRESULT CMyHlink::SetHlinkSite(IHlinkSite *pihlSite)
  69. {
  70. if (_pihlSite) {
  71. _pihlSite->Release();
  72. }
  73. _pihlSite = pihlSite;
  74. if (_pihlSite) {
  75. _pihlSite->AddRefe();
  76. }
  77. return S_OK;
  78. }
  79. HRESULT CMyHlink::GetHlinkSite(IHlinkSite **ppihlSite)
  80. {
  81. *ppihlSite = _pihlSite;
  82. if (_pihlSite) {
  83. _pihlSite->AddRefe();
  84. }
  85. return S_OK;
  86. }
  87. HRESULT CMyHlink::GetMonikerReference(
  88. IMoniker **ppimk,
  89. LPWSTR *ppwzLocation)
  90. {
  91. if (ppimk) {
  92. *ppimk = _pmk;
  93. if (_pmk) {
  94. _pmk->AddRef();
  95. }
  96. }
  97. // Handle ppwszLocation as well!
  98. return S_OK;
  99. }
  100. HRESULT CMyHlink::GetStringReference(LPWSTR *ppwzRefString)
  101. {
  102. return E_NOTIMPL;
  103. }
  104. HRESULT CMyHlink::GetFriendlyName(LPWSTR *ppwzFriendlyName)
  105. {
  106. }
  107. HRESULT CMyHlink::Navigate(
  108. IHlinkFrame *pihlFrame,
  109. DWORD grfHLNF,
  110. LPBC pbc,
  111. DWORD dwbscCookie,
  112. IBindStatusCallback *pibsc,
  113. IHlinkBrowseContext *pihlbc);