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)
45 IPersistStream IPersistStream_iface;
46 IDataObject IDataObject_iface;
50 LPWSTR TargetFrameName;
57 static inline HlinkImpl *impl_from_IHlink(IHlink *iface)
59 return CONTAINING_RECORD(iface, HlinkImpl, IHlink_iface);
63 static inline HlinkImpl* impl_from_IPersistStream( IPersistStream* iface)
65 return CONTAINING_RECORD(iface, HlinkImpl, IPersistStream_iface);
68 static inline HlinkImpl* impl_from_IDataObject( IDataObject* iface)
70 return CONTAINING_RECORD(iface, HlinkImpl, IDataObject_iface);
73 static HRESULT __GetMoniker(HlinkImpl* This, IMoniker** moniker,
78 if (ref_type == HLINKGETREF_DEFAULT)
79 ref_type = HLINKGETREF_RELATIVE;
81 if (ref_type == HLINKGETREF_ABSOLUTE && This->Site)
83 IMoniker *hls_moniker;
85 hres = IHlinkSite_GetMoniker(This->Site, This->SiteData,
86 OLEGETMONIKER_FORCEASSIGN, OLEWHICHMK_CONTAINER, &hls_moniker);
92 hres = IMoniker_ComposeWith(hls_moniker, This->Moniker, FALSE,
94 IMoniker_Release(hls_moniker);
98 *moniker = hls_moniker;
102 *moniker = This->Moniker;
104 IMoniker_AddRef(*moniker);
109 static HRESULT WINAPI IHlink_fnQueryInterface(IHlink* iface, REFIID riid,
112 HlinkImpl *This = impl_from_IHlink(iface);
114 TRACE ("(%p)->(%s,%p)\n", This, debugstr_guid (riid), ppvObj);
118 if (IsEqualIID(riid, &IID_IUnknown) || (IsEqualIID(riid, &IID_IHlink)))
120 else if (IsEqualIID(riid, &IID_IPersistStream))
121 *ppvObj = &This->IPersistStream_iface;
122 else if (IsEqualIID(riid, &IID_IDataObject))
123 *ppvObj = &This->IDataObject_iface;
127 IUnknown_AddRef((IUnknown*)(*ppvObj));
130 return E_NOINTERFACE;
133 static ULONG WINAPI IHlink_fnAddRef (IHlink* iface)
135 HlinkImpl *This = impl_from_IHlink(iface);
136 ULONG refCount = InterlockedIncrement(&This->ref);
138 TRACE("(%p)->(count=%u)\n", This, refCount - 1);
143 static ULONG WINAPI IHlink_fnRelease (IHlink* iface)
145 HlinkImpl *This = impl_from_IHlink(iface);
146 ULONG refCount = InterlockedDecrement(&This->ref);
148 TRACE("(%p)->(count=%u)\n", This, refCount + 1);
152 TRACE("-- destroying IHlink (%p)\n", This);
153 heap_free(This->FriendlyName);
154 heap_free(This->TargetFrameName);
155 heap_free(This->Location);
157 IMoniker_Release(This->Moniker);
159 IHlinkSite_Release(This->Site);
164 static HRESULT WINAPI IHlink_fnSetHlinkSite( IHlink* iface,
165 IHlinkSite* pihlSite, DWORD dwSiteData)
167 HlinkImpl *This = impl_from_IHlink(iface);
169 TRACE("(%p)->(%p %i)\n", This, pihlSite, dwSiteData);
172 IHlinkSite_Release(This->Site);
174 This->Site = pihlSite;
176 IHlinkSite_AddRef(This->Site);
178 This->SiteData = dwSiteData;
183 static HRESULT WINAPI IHlink_fnGetHlinkSite( IHlink* iface,
184 IHlinkSite** ppihlSite, DWORD *pdwSiteData)
186 HlinkImpl *This = impl_from_IHlink(iface);
188 TRACE("(%p)->(%p %p)\n", This, ppihlSite, pdwSiteData);
190 *ppihlSite = This->Site;
193 IHlinkSite_AddRef(This->Site);
194 *pdwSiteData = This->SiteData;
200 static HRESULT WINAPI IHlink_fnSetMonikerReference( IHlink* iface,
201 DWORD rfHLSETF, IMoniker *pmkTarget, LPCWSTR pwzLocation)
203 HlinkImpl *This = impl_from_IHlink(iface);
205 TRACE("(%p)->(%i %p %s)\n", This, rfHLSETF, pmkTarget,
206 debugstr_w(pwzLocation));
210 if(!(rfHLSETF & (HLINKSETF_TARGET | HLINKSETF_LOCATION)))
213 if(rfHLSETF & HLINKSETF_TARGET){
215 IMoniker_Release(This->Moniker);
217 This->Moniker = pmkTarget;
220 LPOLESTR display_name;
221 IMoniker_AddRef(This->Moniker);
222 IMoniker_GetDisplayName(This->Moniker, NULL, NULL, &display_name);
223 This->absolute = display_name && strchrW(display_name, ':');
224 CoTaskMemFree(display_name);
228 if(rfHLSETF & HLINKSETF_LOCATION){
229 heap_free(This->Location);
230 This->Location = hlink_strdupW( pwzLocation );
236 static HRESULT WINAPI IHlink_fnSetStringReference(IHlink* iface,
237 DWORD grfHLSETF, LPCWSTR pwzTarget, LPCWSTR pwzLocation)
239 HlinkImpl *This = impl_from_IHlink(iface);
241 TRACE("(%p)->(%i %s %s)\n", This, grfHLSETF, debugstr_w(pwzTarget),
242 debugstr_w(pwzLocation));
244 if(grfHLSETF > (HLINKSETF_TARGET | HLINKSETF_LOCATION) &&
245 grfHLSETF < -(HLINKSETF_TARGET | HLINKSETF_LOCATION))
248 if (grfHLSETF & HLINKSETF_TARGET)
252 IMoniker_Release(This->Moniker);
253 This->Moniker = NULL;
255 if (pwzTarget && *pwzTarget)
258 IBindCtx *pbc = NULL;
262 r = CreateBindCtx(0, &pbc);
264 return E_OUTOFMEMORY;
266 r = MkParseDisplayName(pbc, pwzTarget, &eaten, &pMon);
267 IBindCtx_Release(pbc);
271 LPCWSTR p = strchrW(pwzTarget, ':');
272 if (p && (p - pwzTarget > 1))
273 r = CreateURLMoniker(NULL, pwzTarget, &pMon);
275 r = CreateFileMoniker(pwzTarget, &pMon);
278 ERR("couldn't create moniker for %s, failed with error 0x%08x\n",
279 debugstr_w(pwzTarget), r);
284 IHlink_SetMonikerReference(iface, HLINKSETF_TARGET, pMon, NULL);
285 IMoniker_Release(pMon);
289 if (grfHLSETF & HLINKSETF_LOCATION)
291 heap_free(This->Location);
292 This->Location = NULL;
293 if (pwzLocation && *pwzLocation)
294 This->Location = hlink_strdupW( pwzLocation );
300 static HRESULT WINAPI IHlink_fnGetMonikerReference(IHlink* iface,
301 DWORD dwWhichRef, IMoniker **ppimkTarget, LPWSTR *ppwzLocation)
303 HlinkImpl *This = impl_from_IHlink(iface);
305 TRACE("(%p) -> (%i %p %p)\n", This, dwWhichRef, ppimkTarget,
310 HRESULT hres = __GetMoniker(This, ppimkTarget, dwWhichRef);
314 *ppwzLocation = NULL;
320 IHlink_GetStringReference(iface, dwWhichRef, NULL, ppwzLocation);
325 static HRESULT WINAPI IHlink_fnGetStringReference (IHlink* iface,
326 DWORD dwWhichRef, LPWSTR *ppwzTarget, LPWSTR *ppwzLocation)
328 HlinkImpl *This = impl_from_IHlink(iface);
330 TRACE("(%p) -> (%i %p %p)\n", This, dwWhichRef, ppwzTarget, ppwzLocation);
332 if(dwWhichRef != -1 && dwWhichRef & ~(HLINKGETREF_DEFAULT | HLINKGETREF_ABSOLUTE | HLINKGETREF_RELATIVE))
337 *ppwzLocation = NULL;
344 HRESULT hres = __GetMoniker(This, &mon, dwWhichRef);
348 *ppwzLocation = NULL;
355 CreateBindCtx( 0, &pbc);
356 IMoniker_GetDisplayName(mon, pbc, NULL, ppwzTarget);
357 IBindCtx_Release(pbc);
358 IMoniker_Release(mon);
364 *ppwzLocation = hlink_co_strdupW( This->Location );
366 TRACE("(Target: %s Location: %s)\n",
367 (ppwzTarget)?debugstr_w(*ppwzTarget):"<NULL>",
368 (ppwzLocation)?debugstr_w(*ppwzLocation):"<NULL>");
373 static HRESULT WINAPI IHlink_fnSetFriendlyName (IHlink *iface,
374 LPCWSTR pwzFriendlyName)
376 HlinkImpl *This = impl_from_IHlink(iface);
378 TRACE("(%p) -> (%s)\n", This, debugstr_w(pwzFriendlyName));
380 heap_free(This->FriendlyName);
381 This->FriendlyName = hlink_strdupW( pwzFriendlyName );
386 static HRESULT WINAPI IHlink_fnGetFriendlyName (IHlink* iface,
387 DWORD grfHLFNAMEF, LPWSTR* ppwzFriendlyName)
389 HlinkImpl *This = impl_from_IHlink(iface);
391 TRACE("(%p) -> (%i %p)\n", This, grfHLFNAMEF, ppwzFriendlyName);
393 /* FIXME: Only using explicitly set and cached friendly names */
395 if (This->FriendlyName)
396 *ppwzFriendlyName = hlink_co_strdupW( This->FriendlyName );
400 HRESULT hres = __GetMoniker(This, &moniker, HLINKGETREF_DEFAULT);
403 *ppwzFriendlyName = NULL;
409 CreateBindCtx(0, &bcxt);
411 IMoniker_GetDisplayName(moniker, bcxt, NULL, ppwzFriendlyName);
412 IBindCtx_Release(bcxt);
413 IMoniker_Release(moniker);
416 *ppwzFriendlyName = NULL;
422 static HRESULT WINAPI IHlink_fnSetTargetFrameName(IHlink* iface,
423 LPCWSTR pwzTargetFramename)
425 HlinkImpl *This = impl_from_IHlink(iface);
426 TRACE("(%p)->(%s)\n", This, debugstr_w(pwzTargetFramename));
428 heap_free(This->TargetFrameName);
429 This->TargetFrameName = hlink_strdupW( pwzTargetFramename );
434 static HRESULT WINAPI IHlink_fnGetTargetFrameName(IHlink* iface,
435 LPWSTR *ppwzTargetFrameName)
437 HlinkImpl *This = impl_from_IHlink(iface);
439 TRACE("(%p)->(%p)\n", This, ppwzTargetFrameName);
441 if(!This->TargetFrameName) {
442 *ppwzTargetFrameName = NULL;
446 *ppwzTargetFrameName = hlink_co_strdupW( This->TargetFrameName );
447 if(!*ppwzTargetFrameName)
448 return E_OUTOFMEMORY;
453 static HRESULT WINAPI IHlink_fnGetMiscStatus(IHlink* iface, DWORD* pdwStatus)
459 static HRESULT WINAPI IHlink_fnNavigate(IHlink* iface, DWORD grfHLNF, LPBC pbc,
460 IBindStatusCallback *pbsc, IHlinkBrowseContext *phbc)
462 HlinkImpl *This = impl_from_IHlink(iface);
463 IMoniker *mon = NULL;
466 FIXME("Semi-Stub:(%p)->(%i %p %p %p)\n", This, grfHLNF, pbc, pbsc, phbc);
468 r = __GetMoniker(This, &mon, HLINKGETREF_ABSOLUTE);
469 TRACE("Moniker %p\n", mon);
474 IHlinkTarget *target = NULL;
476 CreateBindCtx(0, &bcxt);
478 RegisterBindStatusCallback(bcxt, pbsc, NULL, 0);
480 r = IMoniker_BindToObject(mon, bcxt, NULL, &IID_IHlinkTarget,
482 TRACE("IHlinkTarget returned 0x%x\n", r);
485 IHlinkTarget_SetBrowseContext(target, phbc);
486 IHlinkTarget_Navigate(target, grfHLNF, This->Location);
487 IHlinkTarget_Release(target);
491 static const WCHAR szOpen[] = {'o','p','e','n',0};
492 LPWSTR target = NULL;
494 r = IHlink_GetStringReference(iface, HLINKGETREF_DEFAULT, &target, NULL);
495 if (SUCCEEDED(r) && target)
497 ShellExecuteW(NULL, szOpen, target, NULL, NULL, SW_SHOW);
498 CoTaskMemFree(target);
502 RevokeBindStatusCallback(bcxt, pbsc);
504 IBindCtx_Release(bcxt);
505 IMoniker_Release(mon);
509 IHlinkSite_OnNavigationComplete(This->Site, This->SiteData, 0, r, NULL);
511 TRACE("Finished Navigation\n");
515 static HRESULT WINAPI IHlink_fnSetAdditonalParams(IHlink* iface,
516 LPCWSTR pwzAdditionalParams)
518 TRACE("Not implemented in native IHlink\n");
522 static HRESULT WINAPI IHlink_fnGetAdditionalParams(IHlink* iface,
523 LPWSTR* ppwzAdditionalParams)
525 TRACE("Not implemented in native IHlink\n");
529 static const IHlinkVtbl hlvt =
531 IHlink_fnQueryInterface,
534 IHlink_fnSetHlinkSite,
535 IHlink_fnGetHlinkSite,
536 IHlink_fnSetMonikerReference,
537 IHlink_fnGetMonikerReference,
538 IHlink_fnSetStringReference,
539 IHlink_fnGetStringReference,
540 IHlink_fnSetFriendlyName,
541 IHlink_fnGetFriendlyName,
542 IHlink_fnSetTargetFrameName,
543 IHlink_fnGetTargetFrameName,
544 IHlink_fnGetMiscStatus,
546 IHlink_fnSetAdditonalParams,
547 IHlink_fnGetAdditionalParams
550 static HRESULT WINAPI IDataObject_fnQueryInterface(IDataObject* iface,
551 REFIID riid, LPVOID *ppvObj)
553 HlinkImpl *This = impl_from_IDataObject(iface);
555 return IHlink_QueryInterface(&This->IHlink_iface, riid, ppvObj);
558 static ULONG WINAPI IDataObject_fnAddRef (IDataObject* iface)
560 HlinkImpl *This = impl_from_IDataObject(iface);
562 return IHlink_AddRef(&This->IHlink_iface);
565 static ULONG WINAPI IDataObject_fnRelease (IDataObject* iface)
567 HlinkImpl *This = impl_from_IDataObject(iface);
569 return IHlink_Release(&This->IHlink_iface);
572 static HRESULT WINAPI IDataObject_fnGetData(IDataObject* iface,
573 FORMATETC* pformatetcIn, STGMEDIUM* pmedium)
579 static HRESULT WINAPI IDataObject_fnGetDataHere(IDataObject* iface,
580 FORMATETC* pformatetc, STGMEDIUM* pmedium)
586 static HRESULT WINAPI IDataObject_fnQueryGetData(IDataObject* iface,
587 FORMATETC* pformatetc)
593 static HRESULT WINAPI IDataObject_fnGetConicalFormatEtc(IDataObject* iface,
594 FORMATETC* pformatetcIn, FORMATETC* pformatetcOut)
600 static HRESULT WINAPI IDataObject_fnSetData(IDataObject* iface,
601 FORMATETC* pformatetc, STGMEDIUM* pmedium, BOOL fRelease)
607 static HRESULT WINAPI IDataObject_fnEnumFormatEtc(IDataObject* iface,
608 DWORD dwDirection, IEnumFORMATETC** ppenumFormatEtc)
614 static HRESULT WINAPI IDataObject_fnDAdvise(IDataObject* iface,
615 FORMATETC* pformatetc, DWORD advf, IAdviseSink* pAdvSink,
616 DWORD* pdwConnection)
622 static HRESULT WINAPI IDataObject_fnDUnadvise(IDataObject* iface,
629 static HRESULT WINAPI IDataObject_fnEnumDAdvise(IDataObject* iface,
630 IEnumSTATDATA** ppenumAdvise)
636 static const IDataObjectVtbl dovt =
638 IDataObject_fnQueryInterface,
639 IDataObject_fnAddRef,
640 IDataObject_fnRelease,
641 IDataObject_fnGetData,
642 IDataObject_fnGetDataHere,
643 IDataObject_fnQueryGetData,
644 IDataObject_fnGetConicalFormatEtc,
645 IDataObject_fnSetData,
646 IDataObject_fnEnumFormatEtc,
647 IDataObject_fnDAdvise,
648 IDataObject_fnDUnadvise,
649 IDataObject_fnEnumDAdvise
652 static HRESULT WINAPI IPersistStream_fnQueryInterface(IPersistStream* iface,
653 REFIID riid, LPVOID *ppvObj)
655 HlinkImpl *This = impl_from_IPersistStream(iface);
656 TRACE("(%p)\n", This);
657 return IHlink_QueryInterface(&This->IHlink_iface, riid, ppvObj);
660 static ULONG WINAPI IPersistStream_fnAddRef (IPersistStream* iface)
662 HlinkImpl *This = impl_from_IPersistStream(iface);
663 TRACE("(%p)\n", This);
664 return IHlink_AddRef(&This->IHlink_iface);
667 static ULONG WINAPI IPersistStream_fnRelease (IPersistStream* iface)
669 HlinkImpl *This = impl_from_IPersistStream(iface);
670 TRACE("(%p)\n", This);
671 return IHlink_Release(&This->IHlink_iface);
674 static HRESULT WINAPI IPersistStream_fnGetClassID(IPersistStream* iface,
677 HlinkImpl *This = impl_from_IPersistStream(iface);
678 TRACE("(%p)\n", This);
679 *pClassID = CLSID_StdHlink;
683 static HRESULT WINAPI IPersistStream_fnIsDirty(IPersistStream* iface)
689 static HRESULT write_hlink_string(IStream *pStm, LPCWSTR str)
694 TRACE("(%p, %s)\n", pStm, debugstr_w(str));
696 len = strlenW(str) + 1;
698 hr = IStream_Write(pStm, &len, sizeof(len), NULL);
699 if (FAILED(hr)) return hr;
701 hr = IStream_Write(pStm, str, len * sizeof(WCHAR), NULL);
702 if (FAILED(hr)) return hr;
707 static inline ULONG size_hlink_string(LPCWSTR str)
709 return sizeof(DWORD) + (strlenW(str) + 1) * sizeof(WCHAR);
712 static HRESULT read_hlink_string(IStream *pStm, LPWSTR *out_str)
719 hr = IStream_Read(pStm, &len, sizeof(len), &read);
720 if (FAILED(hr)) return hr;
721 if (read != sizeof(len)) return STG_E_READFAULT;
723 TRACE("read len %d\n", len);
725 str = heap_alloc(len * sizeof(WCHAR));
726 if (!str) return E_OUTOFMEMORY;
728 hr = IStream_Read(pStm, str, len * sizeof(WCHAR), &read);
734 if (read != len * sizeof(WCHAR))
737 return STG_E_READFAULT;
739 TRACE("read string %s\n", debugstr_w(str));
745 static HRESULT WINAPI IPersistStream_fnLoad(IPersistStream* iface,
751 HlinkImpl *This = impl_from_IPersistStream(iface);
753 r = IStream_Read(pStm, hdr, sizeof(hdr), &read);
754 if (read != sizeof(hdr) || (hdr[0] != HLINK_SAVE_MAGIC))
759 if (hdr[1] & ~HLINK_SAVE_ALL)
760 FIXME("unknown flag(s) 0x%x\n", hdr[1] & ~HLINK_SAVE_ALL);
762 if (hdr[1] & HLINK_SAVE_TARGET_FRAME_PRESENT)
764 TRACE("loading target frame name\n");
765 r = read_hlink_string(pStm, &This->TargetFrameName);
766 if (FAILED(r)) goto end;
769 if (hdr[1] & HLINK_SAVE_FRIENDLY_PRESENT)
771 TRACE("loading target friendly name\n");
773 FIXME("0x4 flag not present with friendly name flag - not sure what this means\n");
774 r = read_hlink_string(pStm, &This->FriendlyName);
775 if (FAILED(r)) goto end;
778 if (hdr[1] & HLINK_SAVE_MONIKER_PRESENT)
780 TRACE("loading moniker\n");
781 r = OleLoadFromStream(pStm, &IID_IMoniker, (LPVOID*)&(This->Moniker));
784 This->absolute = hdr[1] & HLINK_SAVE_MONIKER_IS_ABSOLUTE ? TRUE : FALSE;
787 if (hdr[1] & HLINK_SAVE_LOCATION_PRESENT)
789 TRACE("loading location\n");
790 r = read_hlink_string(pStm, &This->Location);
791 if (FAILED(r)) goto end;
795 TRACE("Load Result 0x%x (%p)\n", r, This->Moniker);
800 static HRESULT WINAPI IPersistStream_fnSave(IPersistStream* iface,
801 IStream* pStm, BOOL fClearDirty)
804 HlinkImpl *This = impl_from_IPersistStream(iface);
808 TRACE("(%p) Moniker(%p)\n", This, This->Moniker);
810 r = __GetMoniker(This, &moniker, HLINKGETREF_DEFAULT);
815 hdr[0] = HLINK_SAVE_MAGIC;
819 hdr[1] |= HLINK_SAVE_MONIKER_PRESENT;
821 hdr[1] |= HLINK_SAVE_MONIKER_IS_ABSOLUTE;
823 hdr[1] |= HLINK_SAVE_LOCATION_PRESENT;
824 if (This->FriendlyName)
825 hdr[1] |= HLINK_SAVE_FRIENDLY_PRESENT | 4 /* FIXME */;
826 if (This->TargetFrameName)
827 hdr[1] |= HLINK_SAVE_TARGET_FRAME_PRESENT;
829 IStream_Write(pStm, hdr, sizeof(hdr), NULL);
831 if (This->TargetFrameName)
833 r = write_hlink_string(pStm, This->TargetFrameName);
834 if (FAILED(r)) goto end;
837 if (This->FriendlyName)
839 r = write_hlink_string(pStm, This->FriendlyName);
840 if (FAILED(r)) goto end;
845 IPersistStream* monstream;
848 IMoniker_QueryInterface(moniker, &IID_IPersistStream,
849 (LPVOID*)&monstream);
852 r = OleSaveToStream(monstream, pStm);
853 IPersistStream_Release(monstream);
855 if (FAILED(r)) goto end;
860 r = write_hlink_string(pStm, This->Location);
861 if (FAILED(r)) goto end;
865 if (moniker) IMoniker_Release(moniker);
866 TRACE("Save Result 0x%x\n", r);
871 static HRESULT WINAPI IPersistStream_fnGetSizeMax(IPersistStream* iface,
872 ULARGE_INTEGER* pcbSize)
875 HlinkImpl *This = impl_from_IPersistStream(iface);
878 TRACE("(%p) Moniker(%p)\n", This, This->Moniker);
880 pcbSize->QuadPart = sizeof(DWORD)*2;
882 if (This->TargetFrameName)
883 pcbSize->QuadPart += size_hlink_string(This->TargetFrameName);
885 if (This->FriendlyName)
886 pcbSize->QuadPart += size_hlink_string(This->FriendlyName);
888 r = __GetMoniker(This, &moniker, HLINKGETREF_DEFAULT);
895 IPersistStream* monstream = NULL;
896 IMoniker_QueryInterface(moniker, &IID_IPersistStream,
897 (LPVOID*)&monstream);
900 ULARGE_INTEGER mon_size;
901 r = IPersistStream_GetSizeMax(monstream, &mon_size);
902 pcbSize->QuadPart += mon_size.QuadPart;
903 IPersistStream_Release(monstream);
905 IMoniker_Release(moniker);
909 pcbSize->QuadPart += size_hlink_string(This->Location);
914 static const IPersistStreamVtbl psvt =
916 IPersistStream_fnQueryInterface,
917 IPersistStream_fnAddRef,
918 IPersistStream_fnRelease,
919 IPersistStream_fnGetClassID,
920 IPersistStream_fnIsDirty,
921 IPersistStream_fnLoad,
922 IPersistStream_fnSave,
923 IPersistStream_fnGetSizeMax,
926 HRESULT HLink_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv)
930 TRACE("unkOut=%p riid=%s\n", pUnkOuter, debugstr_guid(riid));
934 return CLASS_E_NOAGGREGATION;
936 hl = heap_alloc_zero(sizeof(HlinkImpl));
938 return E_OUTOFMEMORY;
941 hl->IHlink_iface.lpVtbl = &hlvt;
942 hl->IPersistStream_iface.lpVtbl = &psvt;
943 hl->IDataObject_iface.lpVtbl = &dovt;