2 * Implementation of hyperlinking (hlink.dll)
4 * Copyright 2005 Aric Stewart for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "hlink_private.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(hlink);
30 #define HLINK_SAVE_MAGIC 0x00000002
31 #define HLINK_SAVE_MONIKER_PRESENT 0x01
32 #define HLINK_SAVE_MONIKER_IS_ABSOLUTE 0x02
33 #define HLINK_SAVE_LOCATION_PRESENT 0x08
34 #define HLINK_SAVE_FRIENDLY_PRESENT 0x10
35 /* 0x20, 0x40 unknown */
36 #define HLINK_SAVE_TARGET_FRAME_PRESENT 0x80
38 #define HLINK_SAVE_ALL (HLINK_SAVE_TARGET_FRAME_PRESENT|HLINK_SAVE_FRIENDLY_PRESENT|HLINK_SAVE_LOCATION_PRESENT|0x04|HLINK_SAVE_MONIKER_IS_ABSOLUTE|HLINK_SAVE_MONIKER_PRESENT)
40 static const IHlinkVtbl hlvt;
41 static const IPersistStreamVtbl psvt;
42 static const IDataObjectVtbl dovt;
46 const IHlinkVtbl *lpVtbl;
49 const IPersistStreamVtbl *lpPSVtbl;
50 const IDataObjectVtbl *lpDOVtbl;
54 LPWSTR TargetFrameName;
62 static inline HlinkImpl* HlinkImpl_from_IPersistStream( IPersistStream* iface)
64 return (HlinkImpl*) ((CHAR*)iface - FIELD_OFFSET(HlinkImpl, lpPSVtbl));
67 static inline HlinkImpl* HlinkImpl_from_IDataObject( IDataObject* iface)
69 return (HlinkImpl*) ((CHAR*)iface - FIELD_OFFSET(HlinkImpl, lpDOVtbl));
72 static HRESULT __GetMoniker(HlinkImpl* This, IMoniker** moniker,
77 if (ref_type == HLINKGETREF_DEFAULT)
78 ref_type = HLINKGETREF_RELATIVE;
80 if (ref_type == HLINKGETREF_ABSOLUTE && This->Site)
82 IMoniker *hls_moniker;
84 hres = IHlinkSite_GetMoniker(This->Site, This->SiteData,
85 OLEGETMONIKER_FORCEASSIGN, OLEWHICHMK_CONTAINER, &hls_moniker);
91 hres = IMoniker_ComposeWith(hls_moniker, This->Moniker, FALSE,
93 IMoniker_Release(hls_moniker);
97 *moniker = hls_moniker;
101 *moniker = This->Moniker;
103 IMoniker_AddRef(*moniker);
108 HRESULT WINAPI HLink_Constructor(IUnknown *pUnkOuter, REFIID riid,
113 TRACE("unkOut=%p riid=%s\n", pUnkOuter, debugstr_guid(riid));
117 return CLASS_E_NOAGGREGATION;
119 hl = heap_alloc_zero(sizeof(HlinkImpl));
121 return E_OUTOFMEMORY;
125 hl->lpPSVtbl = &psvt;
126 hl->lpDOVtbl = &dovt;
132 static HRESULT WINAPI IHlink_fnQueryInterface(IHlink* iface, REFIID riid,
135 HlinkImpl *This = (HlinkImpl*)iface;
137 TRACE ("(%p)->(%s,%p)\n", This, debugstr_guid (riid), ppvObj);
141 if (IsEqualIID(riid, &IID_IUnknown) || (IsEqualIID(riid, &IID_IHlink)))
143 else if (IsEqualIID(riid, &IID_IPersistStream))
144 *ppvObj = &(This->lpPSVtbl);
145 else if (IsEqualIID(riid, &IID_IDataObject))
146 *ppvObj = &(This->lpDOVtbl);
150 IUnknown_AddRef((IUnknown*)(*ppvObj));
153 return E_NOINTERFACE;
156 static ULONG WINAPI IHlink_fnAddRef (IHlink* iface)
158 HlinkImpl *This = (HlinkImpl*)iface;
159 ULONG refCount = InterlockedIncrement(&This->ref);
161 TRACE("(%p)->(count=%u)\n", This, refCount - 1);
166 static ULONG WINAPI IHlink_fnRelease (IHlink* iface)
168 HlinkImpl *This = (HlinkImpl*)iface;
169 ULONG refCount = InterlockedDecrement(&This->ref);
171 TRACE("(%p)->(count=%u)\n", This, refCount + 1);
175 TRACE("-- destroying IHlink (%p)\n", This);
176 heap_free(This->FriendlyName);
177 heap_free(This->TargetFrameName);
178 heap_free(This->Location);
180 IMoniker_Release(This->Moniker);
182 IHlinkSite_Release(This->Site);
187 static HRESULT WINAPI IHlink_fnSetHlinkSite( IHlink* iface,
188 IHlinkSite* pihlSite, DWORD dwSiteData)
190 HlinkImpl *This = (HlinkImpl*)iface;
192 TRACE("(%p)->(%p %i)\n", This, pihlSite, dwSiteData);
195 IHlinkSite_Release(This->Site);
197 This->Site = pihlSite;
199 IHlinkSite_AddRef(This->Site);
201 This->SiteData = dwSiteData;
206 static HRESULT WINAPI IHlink_fnGetHlinkSite( IHlink* iface,
207 IHlinkSite** ppihlSite, DWORD *pdwSiteData)
209 HlinkImpl *This = (HlinkImpl*)iface;
211 TRACE("(%p)->(%p %p)\n", This, ppihlSite, pdwSiteData);
213 *ppihlSite = This->Site;
216 IHlinkSite_AddRef(This->Site);
217 *pdwSiteData = This->SiteData;
223 static HRESULT WINAPI IHlink_fnSetMonikerReference( IHlink* iface,
224 DWORD rfHLSETF, IMoniker *pmkTarget, LPCWSTR pwzLocation)
226 HlinkImpl *This = (HlinkImpl*)iface;
228 TRACE("(%p)->(%i %p %s)\n", This, rfHLSETF, pmkTarget,
229 debugstr_w(pwzLocation));
233 if(!(rfHLSETF & (HLINKSETF_TARGET | HLINKSETF_LOCATION)))
236 if(rfHLSETF & HLINKSETF_TARGET){
238 IMoniker_Release(This->Moniker);
240 This->Moniker = pmkTarget;
243 LPOLESTR display_name;
244 IMoniker_AddRef(This->Moniker);
245 IMoniker_GetDisplayName(This->Moniker, NULL, NULL, &display_name);
246 This->absolute = display_name && strchrW(display_name, ':');
247 CoTaskMemFree(display_name);
251 if(rfHLSETF & HLINKSETF_LOCATION){
252 heap_free(This->Location);
253 This->Location = hlink_strdupW( pwzLocation );
259 static HRESULT WINAPI IHlink_fnSetStringReference(IHlink* iface,
260 DWORD grfHLSETF, LPCWSTR pwzTarget, LPCWSTR pwzLocation)
262 HlinkImpl *This = (HlinkImpl*)iface;
264 TRACE("(%p)->(%i %s %s)\n", This, grfHLSETF, debugstr_w(pwzTarget),
265 debugstr_w(pwzLocation));
267 if(grfHLSETF > (HLINKSETF_TARGET | HLINKSETF_LOCATION) &&
268 grfHLSETF < -(HLINKSETF_TARGET | HLINKSETF_LOCATION))
271 if (grfHLSETF & HLINKSETF_TARGET)
275 IMoniker_Release(This->Moniker);
276 This->Moniker = NULL;
278 if (pwzTarget && *pwzTarget)
281 IBindCtx *pbc = NULL;
285 r = CreateBindCtx(0, &pbc);
287 return E_OUTOFMEMORY;
289 r = MkParseDisplayName(pbc, pwzTarget, &eaten, &pMon);
290 IBindCtx_Release(pbc);
294 LPCWSTR p = strchrW(pwzTarget, ':');
295 if (p && (p - pwzTarget > 1))
296 r = CreateURLMoniker(NULL, pwzTarget, &pMon);
298 r = CreateFileMoniker(pwzTarget, &pMon);
301 ERR("couldn't create moniker for %s, failed with error 0x%08x\n",
302 debugstr_w(pwzTarget), r);
307 IHlink_SetMonikerReference(iface, HLINKSETF_TARGET, pMon, NULL);
308 IMoniker_Release(pMon);
312 if (grfHLSETF & HLINKSETF_LOCATION)
314 heap_free(This->Location);
315 This->Location = NULL;
316 if (pwzLocation && *pwzLocation)
317 This->Location = hlink_strdupW( pwzLocation );
323 static HRESULT WINAPI IHlink_fnGetMonikerReference(IHlink* iface,
324 DWORD dwWhichRef, IMoniker **ppimkTarget, LPWSTR *ppwzLocation)
326 HlinkImpl *This = (HlinkImpl*)iface;
328 TRACE("(%p) -> (%i %p %p)\n", This, dwWhichRef, ppimkTarget,
333 HRESULT hres = __GetMoniker(This, ppimkTarget, dwWhichRef);
337 *ppwzLocation = NULL;
343 IHlink_GetStringReference(iface, dwWhichRef, NULL, ppwzLocation);
348 static HRESULT WINAPI IHlink_fnGetStringReference (IHlink* iface,
349 DWORD dwWhichRef, LPWSTR *ppwzTarget, LPWSTR *ppwzLocation)
351 HlinkImpl *This = (HlinkImpl*)iface;
353 TRACE("(%p) -> (%i %p %p)\n", This, dwWhichRef, ppwzTarget, ppwzLocation);
355 if(dwWhichRef != -1 && dwWhichRef & ~(HLINKGETREF_DEFAULT | HLINKGETREF_ABSOLUTE | HLINKGETREF_RELATIVE))
360 *ppwzLocation = NULL;
367 HRESULT hres = __GetMoniker(This, &mon, dwWhichRef);
371 *ppwzLocation = NULL;
378 CreateBindCtx( 0, &pbc);
379 IMoniker_GetDisplayName(mon, pbc, NULL, ppwzTarget);
380 IBindCtx_Release(pbc);
381 IMoniker_Release(mon);
387 *ppwzLocation = hlink_co_strdupW( This->Location );
389 TRACE("(Target: %s Location: %s)\n",
390 (ppwzTarget)?debugstr_w(*ppwzTarget):"<NULL>",
391 (ppwzLocation)?debugstr_w(*ppwzLocation):"<NULL>");
396 static HRESULT WINAPI IHlink_fnSetFriendlyName (IHlink *iface,
397 LPCWSTR pwzFriendlyName)
399 HlinkImpl *This = (HlinkImpl*)iface;
401 TRACE("(%p) -> (%s)\n", This, debugstr_w(pwzFriendlyName));
403 heap_free(This->FriendlyName);
404 This->FriendlyName = hlink_strdupW( pwzFriendlyName );
409 static HRESULT WINAPI IHlink_fnGetFriendlyName (IHlink* iface,
410 DWORD grfHLFNAMEF, LPWSTR* ppwzFriendlyName)
412 HlinkImpl *This = (HlinkImpl*)iface;
414 TRACE("(%p) -> (%i %p)\n", This, grfHLFNAMEF, ppwzFriendlyName);
416 /* FIXME: Only using explicitly set and cached friendly names */
418 if (This->FriendlyName)
419 *ppwzFriendlyName = hlink_co_strdupW( This->FriendlyName );
423 HRESULT hres = __GetMoniker(This, &moniker, HLINKGETREF_DEFAULT);
426 *ppwzFriendlyName = NULL;
432 CreateBindCtx(0, &bcxt);
434 IMoniker_GetDisplayName(moniker, bcxt, NULL, ppwzFriendlyName);
435 IBindCtx_Release(bcxt);
436 IMoniker_Release(moniker);
439 *ppwzFriendlyName = NULL;
445 static HRESULT WINAPI IHlink_fnSetTargetFrameName(IHlink* iface,
446 LPCWSTR pwzTargetFramename)
448 HlinkImpl *This = (HlinkImpl*)iface;
449 TRACE("(%p)->(%s)\n", This, debugstr_w(pwzTargetFramename));
451 heap_free(This->TargetFrameName);
452 This->TargetFrameName = hlink_strdupW( pwzTargetFramename );
457 static HRESULT WINAPI IHlink_fnGetTargetFrameName(IHlink* iface,
458 LPWSTR *ppwzTargetFrameName)
460 HlinkImpl *This = (HlinkImpl*)iface;
462 TRACE("(%p)->(%p)\n", This, ppwzTargetFrameName);
463 *ppwzTargetFrameName = hlink_co_strdupW( This->TargetFrameName );
468 static HRESULT WINAPI IHlink_fnGetMiscStatus(IHlink* iface, DWORD* pdwStatus)
474 static HRESULT WINAPI IHlink_fnNavigate(IHlink* iface, DWORD grfHLNF, LPBC pbc,
475 IBindStatusCallback *pbsc, IHlinkBrowseContext *phbc)
477 HlinkImpl *This = (HlinkImpl*)iface;
478 IMoniker *mon = NULL;
481 FIXME("Semi-Stub:(%p)->(%i %p %p %p)\n", This, grfHLNF, pbc, pbsc, phbc);
483 r = __GetMoniker(This, &mon, HLINKGETREF_ABSOLUTE);
484 TRACE("Moniker %p\n", mon);
489 IHlinkTarget *target = NULL;
491 CreateBindCtx(0, &bcxt);
493 RegisterBindStatusCallback(bcxt, pbsc, NULL, 0);
495 r = IMoniker_BindToObject(mon, bcxt, NULL, &IID_IHlinkTarget,
497 TRACE("IHlinkTarget returned 0x%x\n", r);
500 IHlinkTarget_SetBrowseContext(target, phbc);
501 IHlinkTarget_Navigate(target, grfHLNF, This->Location);
502 IHlinkTarget_Release(target);
506 static const WCHAR szOpen[] = {'o','p','e','n',0};
507 LPWSTR target = NULL;
509 r = IHlink_GetStringReference(iface, HLINKGETREF_DEFAULT, &target, NULL);
510 if (SUCCEEDED(r) && target)
512 ShellExecuteW(NULL, szOpen, target, NULL, NULL, SW_SHOW);
513 CoTaskMemFree(target);
517 RevokeBindStatusCallback(bcxt, pbsc);
519 IBindCtx_Release(bcxt);
520 IMoniker_Release(mon);
524 IHlinkSite_OnNavigationComplete(This->Site, This->SiteData, 0, r, NULL);
526 TRACE("Finished Navigation\n");
530 static HRESULT WINAPI IHlink_fnSetAdditonalParams(IHlink* iface,
531 LPCWSTR pwzAdditionalParams)
533 TRACE("Not implemented in native IHlink\n");
537 static HRESULT WINAPI IHlink_fnGetAdditionalParams(IHlink* iface,
538 LPWSTR* ppwzAdditionalParams)
540 TRACE("Not implemented in native IHlink\n");
544 static const IHlinkVtbl hlvt =
546 IHlink_fnQueryInterface,
549 IHlink_fnSetHlinkSite,
550 IHlink_fnGetHlinkSite,
551 IHlink_fnSetMonikerReference,
552 IHlink_fnGetMonikerReference,
553 IHlink_fnSetStringReference,
554 IHlink_fnGetStringReference,
555 IHlink_fnSetFriendlyName,
556 IHlink_fnGetFriendlyName,
557 IHlink_fnSetTargetFrameName,
558 IHlink_fnGetTargetFrameName,
559 IHlink_fnGetMiscStatus,
561 IHlink_fnSetAdditonalParams,
562 IHlink_fnGetAdditionalParams
565 static HRESULT WINAPI IDataObject_fnQueryInterface(IDataObject* iface,
566 REFIID riid, LPVOID *ppvObj)
568 HlinkImpl *This = HlinkImpl_from_IDataObject(iface);
570 return IHlink_QueryInterface((IHlink*)This, riid, ppvObj);
573 static ULONG WINAPI IDataObject_fnAddRef (IDataObject* iface)
575 HlinkImpl *This = HlinkImpl_from_IDataObject(iface);
577 return IHlink_AddRef((IHlink*)This);
580 static ULONG WINAPI IDataObject_fnRelease (IDataObject* iface)
582 HlinkImpl *This = HlinkImpl_from_IDataObject(iface);
584 return IHlink_Release((IHlink*)This);
587 static HRESULT WINAPI IDataObject_fnGetData(IDataObject* iface,
588 FORMATETC* pformatetcIn, STGMEDIUM* pmedium)
594 static HRESULT WINAPI IDataObject_fnGetDataHere(IDataObject* iface,
595 FORMATETC* pformatetc, STGMEDIUM* pmedium)
601 static HRESULT WINAPI IDataObject_fnQueryGetData(IDataObject* iface,
602 FORMATETC* pformatetc)
608 static HRESULT WINAPI IDataObject_fnGetConicalFormatEtc(IDataObject* iface,
609 FORMATETC* pformatetcIn, FORMATETC* pformatetcOut)
615 static HRESULT WINAPI IDataObject_fnSetData(IDataObject* iface,
616 FORMATETC* pformatetc, STGMEDIUM* pmedium, BOOL fRelease)
622 static HRESULT WINAPI IDataObject_fnEnumFormatEtc(IDataObject* iface,
623 DWORD dwDirection, IEnumFORMATETC** ppenumFormatEtc)
629 static HRESULT WINAPI IDataObject_fnDAdvise(IDataObject* iface,
630 FORMATETC* pformatetc, DWORD advf, IAdviseSink* pAdvSink,
631 DWORD* pdwConnection)
637 static HRESULT WINAPI IDataObject_fnDUnadvise(IDataObject* iface,
644 static HRESULT WINAPI IDataObject_fnEnumDAdvise(IDataObject* iface,
645 IEnumSTATDATA** ppenumAdvise)
651 static const IDataObjectVtbl dovt =
653 IDataObject_fnQueryInterface,
654 IDataObject_fnAddRef,
655 IDataObject_fnRelease,
656 IDataObject_fnGetData,
657 IDataObject_fnGetDataHere,
658 IDataObject_fnQueryGetData,
659 IDataObject_fnGetConicalFormatEtc,
660 IDataObject_fnSetData,
661 IDataObject_fnEnumFormatEtc,
662 IDataObject_fnDAdvise,
663 IDataObject_fnDUnadvise,
664 IDataObject_fnEnumDAdvise
667 static HRESULT WINAPI IPersistStream_fnQueryInterface(IPersistStream* iface,
668 REFIID riid, LPVOID *ppvObj)
670 HlinkImpl *This = HlinkImpl_from_IPersistStream(iface);
671 TRACE("(%p)\n", This);
672 return IHlink_QueryInterface((IHlink*)This, riid, ppvObj);
675 static ULONG WINAPI IPersistStream_fnAddRef (IPersistStream* iface)
677 HlinkImpl *This = HlinkImpl_from_IPersistStream(iface);
678 TRACE("(%p)\n", This);
679 return IHlink_AddRef((IHlink*)This);
682 static ULONG WINAPI IPersistStream_fnRelease (IPersistStream* iface)
684 HlinkImpl *This = HlinkImpl_from_IPersistStream(iface);
685 TRACE("(%p)\n", This);
686 return IHlink_Release((IHlink*)This);
689 static HRESULT WINAPI IPersistStream_fnGetClassID(IPersistStream* iface,
692 HlinkImpl *This = HlinkImpl_from_IPersistStream(iface);
693 TRACE("(%p)\n", This);
694 *pClassID = CLSID_StdHlink;
698 static HRESULT WINAPI IPersistStream_fnIsDirty(IPersistStream* iface)
704 static HRESULT write_hlink_string(IStream *pStm, LPCWSTR str)
709 TRACE("(%p, %s)\n", pStm, debugstr_w(str));
711 len = strlenW(str) + 1;
713 hr = IStream_Write(pStm, &len, sizeof(len), NULL);
714 if (FAILED(hr)) return hr;
716 hr = IStream_Write(pStm, str, len * sizeof(WCHAR), NULL);
717 if (FAILED(hr)) return hr;
722 static inline ULONG size_hlink_string(LPCWSTR str)
724 return sizeof(DWORD) + (strlenW(str) + 1) * sizeof(WCHAR);
727 static HRESULT read_hlink_string(IStream *pStm, LPWSTR *out_str)
734 hr = IStream_Read(pStm, &len, sizeof(len), &read);
735 if (FAILED(hr)) return hr;
736 if (read != sizeof(len)) return STG_E_READFAULT;
738 TRACE("read len %d\n", len);
740 str = heap_alloc(len * sizeof(WCHAR));
741 if (!str) return E_OUTOFMEMORY;
743 hr = IStream_Read(pStm, str, len * sizeof(WCHAR), &read);
749 if (read != len * sizeof(WCHAR))
752 return STG_E_READFAULT;
754 TRACE("read string %s\n", debugstr_w(str));
760 static HRESULT WINAPI IPersistStream_fnLoad(IPersistStream* iface,
766 HlinkImpl *This = HlinkImpl_from_IPersistStream(iface);
768 r = IStream_Read(pStm, hdr, sizeof(hdr), &read);
769 if (read != sizeof(hdr) || (hdr[0] != HLINK_SAVE_MAGIC))
774 if (hdr[1] & ~HLINK_SAVE_ALL)
775 FIXME("unknown flag(s) 0x%x\n", hdr[1] & ~HLINK_SAVE_ALL);
777 if (hdr[1] & HLINK_SAVE_TARGET_FRAME_PRESENT)
779 TRACE("loading target frame name\n");
780 r = read_hlink_string(pStm, &This->TargetFrameName);
781 if (FAILED(r)) goto end;
784 if (hdr[1] & HLINK_SAVE_FRIENDLY_PRESENT)
786 TRACE("loading target friendly name\n");
788 FIXME("0x4 flag not present with friendly name flag - not sure what this means\n");
789 r = read_hlink_string(pStm, &This->FriendlyName);
790 if (FAILED(r)) goto end;
793 if (hdr[1] & HLINK_SAVE_MONIKER_PRESENT)
795 TRACE("loading moniker\n");
796 r = OleLoadFromStream(pStm, &IID_IMoniker, (LPVOID*)&(This->Moniker));
799 This->absolute = hdr[1] & HLINK_SAVE_MONIKER_IS_ABSOLUTE ? TRUE : FALSE;
802 if (hdr[1] & HLINK_SAVE_LOCATION_PRESENT)
804 TRACE("loading location\n");
805 r = read_hlink_string(pStm, &This->Location);
806 if (FAILED(r)) goto end;
810 TRACE("Load Result 0x%x (%p)\n", r, This->Moniker);
815 static HRESULT WINAPI IPersistStream_fnSave(IPersistStream* iface,
816 IStream* pStm, BOOL fClearDirty)
819 HlinkImpl *This = HlinkImpl_from_IPersistStream(iface);
823 TRACE("(%p) Moniker(%p)\n", This, This->Moniker);
825 r = __GetMoniker(This, &moniker, HLINKGETREF_DEFAULT);
830 hdr[0] = HLINK_SAVE_MAGIC;
834 hdr[1] |= HLINK_SAVE_MONIKER_PRESENT;
836 hdr[1] |= HLINK_SAVE_MONIKER_IS_ABSOLUTE;
838 hdr[1] |= HLINK_SAVE_LOCATION_PRESENT;
839 if (This->FriendlyName)
840 hdr[1] |= HLINK_SAVE_FRIENDLY_PRESENT | 4 /* FIXME */;
841 if (This->TargetFrameName)
842 hdr[1] |= HLINK_SAVE_TARGET_FRAME_PRESENT;
844 IStream_Write(pStm, hdr, sizeof(hdr), NULL);
846 if (This->TargetFrameName)
848 r = write_hlink_string(pStm, This->TargetFrameName);
849 if (FAILED(r)) goto end;
852 if (This->FriendlyName)
854 r = write_hlink_string(pStm, This->FriendlyName);
855 if (FAILED(r)) goto end;
860 IPersistStream* monstream;
863 IMoniker_QueryInterface(moniker, &IID_IPersistStream,
864 (LPVOID*)&monstream);
867 r = OleSaveToStream(monstream, pStm);
868 IPersistStream_Release(monstream);
870 if (FAILED(r)) goto end;
875 r = write_hlink_string(pStm, This->Location);
876 if (FAILED(r)) goto end;
880 if (moniker) IMoniker_Release(moniker);
881 TRACE("Save Result 0x%x\n", r);
886 static HRESULT WINAPI IPersistStream_fnGetSizeMax(IPersistStream* iface,
887 ULARGE_INTEGER* pcbSize)
890 HlinkImpl *This = HlinkImpl_from_IPersistStream(iface);
893 TRACE("(%p) Moniker(%p)\n", This, This->Moniker);
895 pcbSize->QuadPart = sizeof(DWORD)*2;
897 if (This->TargetFrameName)
898 pcbSize->QuadPart += size_hlink_string(This->TargetFrameName);
900 if (This->FriendlyName)
901 pcbSize->QuadPart += size_hlink_string(This->FriendlyName);
903 r = __GetMoniker(This, &moniker, HLINKGETREF_DEFAULT);
910 IPersistStream* monstream = NULL;
911 IMoniker_QueryInterface(moniker, &IID_IPersistStream,
912 (LPVOID*)&monstream);
915 ULARGE_INTEGER mon_size;
916 r = IPersistStream_GetSizeMax(monstream, &mon_size);
917 pcbSize->QuadPart += mon_size.QuadPart;
918 IPersistStream_Release(monstream);
920 IMoniker_Release(moniker);
924 pcbSize->QuadPart += size_hlink_string(This->Location);
929 static const IPersistStreamVtbl psvt =
931 IPersistStream_fnQueryInterface,
932 IPersistStream_fnAddRef,
933 IPersistStream_fnRelease,
934 IPersistStream_fnGetClassID,
935 IPersistStream_fnIsDirty,
936 IPersistStream_fnLoad,
937 IPersistStream_fnSave,
938 IPersistStream_fnGetSizeMax,