4 * Copyright 1999 Ulrich Czekalla for Corel Corporation
5 * Copyright 2002 Huw D M Davies for CodeWeavers
6 * Copyright 2005 Jacek Caban for CodeWeavers
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "urlmon_main.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(urlmon
);
35 IMoniker IMoniker_iface
;
36 IUriContainer IUriContainer_iface
;
40 LPOLESTR URLName
; /* URL string identified by this URLmoniker */
43 static inline URLMoniker
*impl_from_IMoniker(IMoniker
*iface
)
45 return CONTAINING_RECORD(iface
, URLMoniker
, IMoniker_iface
);
48 static HRESULT WINAPI
URLMoniker_QueryInterface(IMoniker
*iface
, REFIID riid
, void **ppv
)
50 URLMoniker
*This
= impl_from_IMoniker(iface
);
55 if(IsEqualIID(&IID_IUnknown
, riid
)) {
56 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
58 }else if(IsEqualIID(&IID_IPersist
, riid
)) {
59 TRACE("(%p)->(IID_IPersist %p)\n", This
, ppv
);
61 }else if(IsEqualIID(&IID_IPersistStream
,riid
)) {
62 TRACE("(%p)->(IID_IPersistStream %p)\n", This
, ppv
);
64 }else if(IsEqualIID(&IID_IMoniker
, riid
)) {
65 TRACE("(%p)->(IID_IMoniker %p)\n", This
, ppv
);
67 }else if(IsEqualIID(&IID_IAsyncMoniker
, riid
)) {
68 TRACE("(%p)->(IID_IAsyncMoniker %p)\n", This
, ppv
);
70 }else if(IsEqualIID(&IID_IUriContainer
, riid
)) {
71 TRACE("(%p)->(IID_IUriContainer %p)\n", This
, ppv
);
72 *ppv
= &This
->IUriContainer_iface
;
74 WARN("(%p)->(%s,%p)\n", This
, debugstr_guid(riid
), ppv
);
79 IMoniker_AddRef((IUnknown
*)*ppv
);
83 static ULONG WINAPI
URLMoniker_AddRef(IMoniker
*iface
)
85 URLMoniker
*This
= impl_from_IMoniker(iface
);
86 ULONG refCount
= InterlockedIncrement(&This
->ref
);
88 TRACE("(%p) ref=%u\n",This
, refCount
);
93 static ULONG WINAPI
URLMoniker_Release(IMoniker
*iface
)
95 URLMoniker
*This
= impl_from_IMoniker(iface
);
96 ULONG refCount
= InterlockedDecrement(&This
->ref
);
98 TRACE("(%p) ref=%u\n",This
, refCount
);
101 heap_free(This
->URLName
);
104 URLMON_UnlockModule();
110 static HRESULT WINAPI
URLMoniker_GetClassID(IMoniker
*iface
, CLSID
*pClassID
)
112 URLMoniker
*This
= impl_from_IMoniker(iface
);
114 TRACE("(%p,%p)\n", This
, pClassID
);
119 /* Windows always returns CLSID_StdURLMoniker */
120 *pClassID
= CLSID_StdURLMoniker
;
124 static HRESULT WINAPI
URLMoniker_IsDirty(IMoniker
*iface
)
126 URLMoniker
*This
= impl_from_IMoniker(iface
);
128 TRACE("(%p)\n",This
);
130 /* Note that the OLE-provided implementations of the IPersistStream::IsDirty
131 method in the OLE-provided moniker interfaces always return S_FALSE because
132 their internal state never changes. */
136 static HRESULT WINAPI
URLMoniker_Load(IMoniker
* iface
,IStream
* pStm
)
138 URLMoniker
*This
= impl_from_IMoniker(iface
);
143 TRACE("(%p,%p)\n",This
,pStm
);
150 * Writes a ULONG containing length of unicode string, followed
151 * by that many unicode characters
153 res
= IStream_Read(pStm
, &size
, sizeof(ULONG
), &got
);
155 if(got
== sizeof(ULONG
)) {
156 heap_free(This
->URLName
);
157 This
->URLName
= heap_alloc(size
);
161 res
= IStream_Read(pStm
, This
->URLName
, size
, NULL
);
162 This
->URLName
[size
/sizeof(WCHAR
) - 1] = 0;
172 static HRESULT WINAPI
URLMoniker_Save(IMoniker
*iface
, IStream
* pStm
, BOOL fClearDirty
)
174 URLMoniker
*This
= impl_from_IMoniker(iface
);
178 TRACE("(%p,%p,%d)\n", This
, pStm
, fClearDirty
);
183 size
= (strlenW(This
->URLName
) + 1)*sizeof(WCHAR
);
184 res
=IStream_Write(pStm
,&size
,sizeof(ULONG
),NULL
);
186 res
=IStream_Write(pStm
,This
->URLName
,size
,NULL
);
192 static HRESULT WINAPI
URLMoniker_GetSizeMax(IMoniker
* iface
, ULARGE_INTEGER
*pcbSize
)
194 URLMoniker
*This
= impl_from_IMoniker(iface
);
196 TRACE("(%p,%p)\n",This
,pcbSize
);
201 pcbSize
->QuadPart
= sizeof(ULONG
) + ((strlenW(This
->URLName
)+1) * sizeof(WCHAR
));
205 static HRESULT WINAPI
URLMoniker_BindToObject(IMoniker
*iface
, IBindCtx
* pbc
, IMoniker
*pmkToLeft
,
206 REFIID riid
, void **ppv
)
208 URLMoniker
*This
= impl_from_IMoniker(iface
);
209 IRunningObjectTable
*obj_tbl
;
213 TRACE("(%p)->(%p,%p,%s,%p): stub\n", This
, pbc
, pmkToLeft
, debugstr_guid(riid
), ppv
);
215 hres
= IBindCtx_GetRunningObjectTable(pbc
, &obj_tbl
);
216 if(SUCCEEDED(hres
)) {
217 FIXME("use running object table\n");
218 IRunningObjectTable_Release(obj_tbl
);
221 hres
= CreateUri(This
->URLName
, Uri_CREATE_FILE_USE_DOS_PATH
, 0, &uri
);
225 hres
= bind_to_object(iface
, uri
, pbc
, riid
, ppv
);
231 static HRESULT WINAPI
URLMoniker_BindToStorage(IMoniker
* iface
, IBindCtx
* pbc
,
232 IMoniker
* pmkToLeft
, REFIID riid
, void **ppvObject
)
234 URLMoniker
*This
= impl_from_IMoniker(iface
);
238 TRACE("(%p)->(%p %p %s %p)\n", This
, pbc
, pmkToLeft
, debugstr_guid(riid
), ppvObject
);
241 FIXME("Unsupported pmkToLeft\n");
243 hres
= CreateUri(This
->URLName
, Uri_CREATE_FILE_USE_DOS_PATH
, 0, &uri
);
247 hres
= bind_to_storage(uri
, pbc
, riid
, ppvObject
);
253 static HRESULT WINAPI
URLMoniker_Reduce(IMoniker
*iface
, IBindCtx
*pbc
,
254 DWORD dwReduceHowFar
, IMoniker
**ppmkToLeft
, IMoniker
**ppmkReduced
)
256 URLMoniker
*This
= impl_from_IMoniker(iface
);
258 TRACE("(%p,%p,%d,%p,%p)\n", This
, pbc
, dwReduceHowFar
, ppmkToLeft
, ppmkReduced
);
263 IMoniker_AddRef(iface
);
264 *ppmkReduced
= iface
;
265 return MK_S_REDUCED_TO_SELF
;
268 static HRESULT WINAPI
URLMoniker_ComposeWith(IMoniker
*iface
, IMoniker
*pmkRight
,
269 BOOL fOnlyIfNotGeneric
, IMoniker
**ppmkComposite
)
271 URLMoniker
*This
= impl_from_IMoniker(iface
);
272 FIXME("(%p)->(%p,%d,%p): stub\n",This
,pmkRight
,fOnlyIfNotGeneric
,ppmkComposite
);
276 static HRESULT WINAPI
URLMoniker_Enum(IMoniker
*iface
, BOOL fForward
, IEnumMoniker
**ppenumMoniker
)
278 URLMoniker
*This
= impl_from_IMoniker(iface
);
280 TRACE("(%p,%d,%p)\n", This
, fForward
, ppenumMoniker
);
285 /* Does not support sub-monikers */
286 *ppenumMoniker
= NULL
;
290 static HRESULT WINAPI
URLMoniker_IsEqual(IMoniker
*iface
, IMoniker
*pmkOtherMoniker
)
292 URLMoniker
*This
= impl_from_IMoniker(iface
);
298 TRACE("(%p,%p)\n",This
, pmkOtherMoniker
);
300 if(pmkOtherMoniker
==NULL
)
303 IMoniker_GetClassID(pmkOtherMoniker
,&clsid
);
305 if(!IsEqualCLSID(&clsid
,&CLSID_StdURLMoniker
))
308 res
= CreateBindCtx(0,&bind
);
313 if(SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker
,bind
,NULL
,&urlPath
))) {
314 int result
= lstrcmpiW(urlPath
, This
->URLName
);
315 CoTaskMemFree(urlPath
);
319 IUnknown_Release(bind
);
324 static HRESULT WINAPI
URLMoniker_Hash(IMoniker
*iface
, DWORD
*pdwHash
)
326 URLMoniker
*This
= impl_from_IMoniker(iface
);
327 int h
= 0,i
,skip
,len
;
331 TRACE("(%p,%p)\n",This
,pdwHash
);
340 for(i
= len
; i
> 0; i
--) {
341 h
= (h
* 37) + val
[off
++];
344 /* only sample some characters */
346 for(i
= len
; i
> 0; i
-= skip
, off
+= skip
) {
347 h
= (h
* 39) + val
[off
];
354 static HRESULT WINAPI
URLMoniker_IsRunning(IMoniker
* iface
, IBindCtx
* pbc
,
355 IMoniker
*pmkToLeft
, IMoniker
*pmkNewlyRunning
)
357 URLMoniker
*This
= impl_from_IMoniker(iface
);
358 FIXME("(%p)->(%p,%p,%p): stub\n",This
,pbc
,pmkToLeft
,pmkNewlyRunning
);
362 static HRESULT WINAPI
URLMoniker_GetTimeOfLastChange(IMoniker
*iface
,
363 IBindCtx
*pbc
, IMoniker
*pmkToLeft
, FILETIME
*pFileTime
)
365 URLMoniker
*This
= impl_from_IMoniker(iface
);
366 FIXME("(%p)->(%p,%p,%p): stub\n", This
, pbc
, pmkToLeft
, pFileTime
);
370 static HRESULT WINAPI
URLMoniker_Inverse(IMoniker
*iface
, IMoniker
**ppmk
)
372 URLMoniker
*This
= impl_from_IMoniker(iface
);
373 TRACE("(%p,%p)\n",This
,ppmk
);
374 return MK_E_NOINVERSE
;
377 static HRESULT WINAPI
URLMoniker_CommonPrefixWith(IMoniker
*iface
, IMoniker
*pmkOther
, IMoniker
**ppmkPrefix
)
379 URLMoniker
*This
= impl_from_IMoniker(iface
);
380 FIXME("(%p)->(%p,%p): stub\n",This
,pmkOther
,ppmkPrefix
);
384 static HRESULT WINAPI
URLMoniker_RelativePathTo(IMoniker
*iface
, IMoniker
*pmOther
, IMoniker
**ppmkRelPath
)
386 URLMoniker
*This
= impl_from_IMoniker(iface
);
387 FIXME("(%p)->(%p,%p): stub\n",This
,pmOther
,ppmkRelPath
);
391 static HRESULT WINAPI
URLMoniker_GetDisplayName(IMoniker
*iface
, IBindCtx
*pbc
, IMoniker
*pmkToLeft
,
392 LPOLESTR
*ppszDisplayName
)
394 URLMoniker
*This
= impl_from_IMoniker(iface
);
397 TRACE("(%p,%p,%p,%p)\n", This
, pbc
, pmkToLeft
, ppszDisplayName
);
403 return E_OUTOFMEMORY
;
405 /* FIXME: If this is a partial URL, try and get a URL moniker from SZ_URLCONTEXT in the bind context,
406 then look at pmkToLeft to try and complete the URL
408 len
= lstrlenW(This
->URLName
)+1;
409 *ppszDisplayName
= CoTaskMemAlloc(len
*sizeof(WCHAR
));
410 if(!*ppszDisplayName
)
411 return E_OUTOFMEMORY
;
412 lstrcpyW(*ppszDisplayName
, This
->URLName
);
416 static HRESULT WINAPI
URLMoniker_ParseDisplayName(IMoniker
*iface
, IBindCtx
*pbc
, IMoniker
*pmkToLeft
,
417 LPOLESTR pszDisplayName
, ULONG
*pchEaten
, IMoniker
**ppmkOut
)
419 URLMoniker
*This
= impl_from_IMoniker(iface
);
420 FIXME("(%p)->(%p,%p,%p,%p,%p): stub\n",This
,pbc
,pmkToLeft
,pszDisplayName
,pchEaten
,ppmkOut
);
424 static HRESULT WINAPI
URLMoniker_IsSystemMoniker(IMoniker
*iface
, DWORD
*pwdMksys
)
426 URLMoniker
*This
= impl_from_IMoniker(iface
);
428 TRACE("(%p,%p)\n",This
,pwdMksys
);
433 *pwdMksys
= MKSYS_URLMONIKER
;
437 static const IMonikerVtbl URLMonikerVtbl
=
439 URLMoniker_QueryInterface
,
442 URLMoniker_GetClassID
,
446 URLMoniker_GetSizeMax
,
447 URLMoniker_BindToObject
,
448 URLMoniker_BindToStorage
,
450 URLMoniker_ComposeWith
,
454 URLMoniker_IsRunning
,
455 URLMoniker_GetTimeOfLastChange
,
457 URLMoniker_CommonPrefixWith
,
458 URLMoniker_RelativePathTo
,
459 URLMoniker_GetDisplayName
,
460 URLMoniker_ParseDisplayName
,
461 URLMoniker_IsSystemMoniker
464 static inline URLMoniker
*impl_from_IUriContainer(IUriContainer
*iface
)
466 return CONTAINING_RECORD(iface
, URLMoniker
, IUriContainer_iface
);
469 static HRESULT WINAPI
UriContainer_QueryInterface(IUriContainer
*iface
, REFIID riid
, void **ppv
)
471 URLMoniker
*This
= impl_from_IUriContainer(iface
);
472 return IMoniker_QueryInterface(&This
->IMoniker_iface
, riid
, ppv
);
475 static ULONG WINAPI
UriContainer_AddRef(IUriContainer
*iface
)
477 URLMoniker
*This
= impl_from_IUriContainer(iface
);
478 return IMoniker_AddRef(&This
->IMoniker_iface
);
481 static ULONG WINAPI
UriContainer_Release(IUriContainer
*iface
)
483 URLMoniker
*This
= impl_from_IUriContainer(iface
);
484 return IMoniker_Release(&This
->IMoniker_iface
);
487 static HRESULT WINAPI
UriContainer_GetIUri(IUriContainer
*iface
, IUri
**ppIUri
)
489 URLMoniker
*This
= impl_from_IUriContainer(iface
);
491 FIXME("(%p)->(%p)\n", This
, ppIUri
);
497 static const IUriContainerVtbl UriContainerVtbl
= {
498 UriContainer_QueryInterface
,
500 UriContainer_Release
,
504 static URLMoniker
*alloc_moniker(void)
508 ret
= heap_alloc(sizeof(URLMoniker
));
512 ret
->IMoniker_iface
.lpVtbl
= &URLMonikerVtbl
;
513 ret
->IUriContainer_iface
.lpVtbl
= &UriContainerVtbl
;
520 static HRESULT
URLMoniker_Init(URLMoniker
*This
, LPCOLESTR lpszLeftURLName
, LPCOLESTR lpszURLName
)
525 TRACE("(%p,%s,%s)\n",This
,debugstr_w(lpszLeftURLName
),debugstr_w(lpszURLName
));
527 This
->URLName
= heap_alloc(INTERNET_MAX_URL_LENGTH
*sizeof(WCHAR
));
530 hres
= CoInternetCombineUrl(lpszLeftURLName
, lpszURLName
, URL_FILE_USE_PATHURL
,
531 This
->URLName
, INTERNET_MAX_URL_LENGTH
, &sizeStr
, 0);
533 hres
= CoInternetParseUrl(lpszURLName
, PARSE_CANONICALIZE
, URL_FILE_USE_PATHURL
,
534 This
->URLName
, INTERNET_MAX_URL_LENGTH
, &sizeStr
, 0);
537 heap_free(This
->URLName
);
543 if(sizeStr
!= INTERNET_MAX_URL_LENGTH
)
544 This
->URLName
= heap_realloc(This
->URLName
, (sizeStr
+1)*sizeof(WCHAR
));
546 TRACE("URLName = %s\n", debugstr_w(This
->URLName
));
551 HRESULT
StdURLMoniker_Construct(IUnknown
*outer
, void **ppv
)
553 TRACE("(%p %p)\n", outer
, ppv
);
555 *ppv
= alloc_moniker();
556 return *ppv
? S_OK
: E_OUTOFMEMORY
;
559 /***********************************************************************
560 * CreateURLMonikerEx (URLMON.@)
562 * Create a url moniker.
565 * pmkContext [I] Context
566 * szURL [I] Url to create the moniker for
567 * ppmk [O] Destination for created moniker.
571 * Success: S_OK. ppmk contains the created IMoniker object.
572 * Failure: MK_E_SYNTAX if szURL is not a valid url, or
573 * E_OUTOFMEMORY if memory allocation fails.
575 HRESULT WINAPI
CreateURLMonikerEx(IMoniker
*pmkContext
, LPCWSTR szURL
, IMoniker
**ppmk
, DWORD dwFlags
)
579 LPOLESTR lefturl
= NULL
;
581 TRACE("(%p, %s, %p, %08x)\n", pmkContext
, debugstr_w(szURL
), ppmk
, dwFlags
);
589 if (dwFlags
& URL_MK_UNIFORM
) FIXME("ignoring flag URL_MK_UNIFORM\n");
591 if(!(obj
= alloc_moniker()))
592 return E_OUTOFMEMORY
;
597 IMoniker_IsSystemMoniker(pmkContext
, &dwMksys
);
598 if(dwMksys
== MKSYS_URLMONIKER
&& SUCCEEDED(CreateBindCtx(0, &bind
))) {
599 IMoniker_GetDisplayName(pmkContext
, bind
, NULL
, &lefturl
);
600 TRACE("lefturl = %s\n", debugstr_w(lefturl
));
601 IBindCtx_Release(bind
);
605 hres
= URLMoniker_Init(obj
, lefturl
, szURL
);
606 CoTaskMemFree(lefturl
);
608 hres
= URLMoniker_QueryInterface(&obj
->IMoniker_iface
, &IID_IMoniker
, (void**)ppmk
);
609 IMoniker_Release(&obj
->IMoniker_iface
);
613 /**********************************************************************
614 * CreateURLMoniker (URLMON.@)
616 * Create a url moniker.
619 * pmkContext [I] Context
620 * szURL [I] Url to create the moniker for
621 * ppmk [O] Destination for created moniker.
624 * Success: S_OK. ppmk contains the created IMoniker object.
625 * Failure: MK_E_SYNTAX if szURL is not a valid url, or
626 * E_OUTOFMEMORY if memory allocation fails.
628 HRESULT WINAPI
CreateURLMoniker(IMoniker
*pmkContext
, LPCWSTR szURL
, IMoniker
**ppmk
)
630 return CreateURLMonikerEx(pmkContext
, szURL
, ppmk
, URL_MK_LEGACY
);
633 /***********************************************************************
634 * IsAsyncMoniker (URLMON.@)
636 HRESULT WINAPI
IsAsyncMoniker(IMoniker
*pmk
)
640 TRACE("(%p)\n", pmk
);
643 if(SUCCEEDED(IMoniker_QueryInterface(pmk
, &IID_IAsyncMoniker
, (void**)&am
))) {
644 IUnknown_Release(am
);
650 /***********************************************************************
651 * BindAsyncMoniker (URLMON.@)
653 * Bind a bind status callback to an asynchronous URL Moniker.
656 * pmk [I] Moniker object to bind status callback to
657 * grfOpt [I] Options, seems not used
658 * pbsc [I] Status callback to bind
659 * iidResult [I] Interface to return
660 * ppvResult [O] Resulting asynchronous moniker object
664 * Failure: E_INVALIDARG, if any argument is invalid, or
665 * E_OUTOFMEMORY if memory allocation fails.
667 HRESULT WINAPI
BindAsyncMoniker(IMoniker
*pmk
, DWORD grfOpt
, IBindStatusCallback
*pbsc
, REFIID iidResult
, LPVOID
*ppvResult
)
670 HRESULT hr
= E_INVALIDARG
;
672 TRACE("(%p %08x %p %s %p)\n", pmk
, grfOpt
, pbsc
, debugstr_guid(iidResult
), ppvResult
);
674 if (pmk
&& ppvResult
)
678 hr
= CreateAsyncBindCtx(0, pbsc
, NULL
, &pbc
);
681 hr
= IMoniker_BindToObject(pmk
, pbc
, NULL
, iidResult
, ppvResult
);
682 IBindCtx_Release(pbc
);
688 /***********************************************************************
689 * MkParseDisplayNameEx (URLMON.@)
691 HRESULT WINAPI
MkParseDisplayNameEx(IBindCtx
*pbc
, LPCWSTR szDisplayName
, ULONG
*pchEaten
, LPMONIKER
*ppmk
)
693 TRACE("(%p %s %p %p)\n", pbc
, debugstr_w(szDisplayName
), pchEaten
, ppmk
);
695 if (!pbc
|| !szDisplayName
|| !*szDisplayName
|| !pchEaten
|| !ppmk
)
698 if(is_registered_protocol(szDisplayName
)) {
701 hres
= CreateURLMoniker(NULL
, szDisplayName
, ppmk
);
702 if(SUCCEEDED(hres
)) {
703 *pchEaten
= strlenW(szDisplayName
);
708 return MkParseDisplayName(pbc
, szDisplayName
, pchEaten
, ppmk
);
712 /***********************************************************************
713 * URLDownloadToCacheFileA (URLMON.@)
715 HRESULT WINAPI
URLDownloadToCacheFileA(LPUNKNOWN lpUnkCaller
, LPCSTR szURL
, LPSTR szFileName
,
716 DWORD dwBufLength
, DWORD dwReserved
, LPBINDSTATUSCALLBACK pBSC
)
718 LPWSTR url
= NULL
, file_name
= NULL
;
722 TRACE("(%p %s %p %d %d %p)\n", lpUnkCaller
, debugstr_a(szURL
), szFileName
,
723 dwBufLength
, dwReserved
, pBSC
);
726 len
= MultiByteToWideChar(CP_ACP
, 0, szURL
, -1, NULL
, 0);
727 url
= heap_alloc(len
*sizeof(WCHAR
));
728 MultiByteToWideChar(CP_ACP
, 0, szURL
, -1, url
, len
);
732 file_name
= heap_alloc(dwBufLength
*sizeof(WCHAR
));
734 hres
= URLDownloadToCacheFileW(lpUnkCaller
, url
, file_name
, dwBufLength
*sizeof(WCHAR
),
737 if(SUCCEEDED(hres
) && file_name
)
738 WideCharToMultiByte(CP_ACP
, 0, file_name
, -1, szFileName
, dwBufLength
, NULL
, NULL
);
741 heap_free(file_name
);
746 /***********************************************************************
747 * URLDownloadToCacheFileW (URLMON.@)
749 HRESULT WINAPI
URLDownloadToCacheFileW(LPUNKNOWN lpUnkCaller
, LPCWSTR szURL
, LPWSTR szFileName
,
750 DWORD dwBufLength
, DWORD dwReserved
, LPBINDSTATUSCALLBACK pBSC
)
752 WCHAR cache_path
[MAX_PATH
+ 1];
753 FILETIME expire
, modified
;
757 static WCHAR header
[] = {
758 'H','T','T','P','/','1','.','0',' ','2','0','0',' ',
759 'O','K','\\','r','\\','n','\\','r','\\','n',0
762 TRACE("(%p, %s, %p, %d, %d, %p)\n", lpUnkCaller
, debugstr_w(szURL
),
763 szFileName
, dwBufLength
, dwReserved
, pBSC
);
765 if (!szURL
|| !szFileName
)
768 ext
= PathFindExtensionW(szURL
);
770 if (!CreateUrlCacheEntryW(szURL
, 0, ext
, cache_path
, 0))
773 hr
= URLDownloadToFileW(lpUnkCaller
, szURL
, cache_path
, 0, pBSC
);
777 expire
.dwHighDateTime
= 0;
778 expire
.dwLowDateTime
= 0;
779 modified
.dwHighDateTime
= 0;
780 modified
.dwLowDateTime
= 0;
782 if (!CommitUrlCacheEntryW(szURL
, cache_path
, expire
, modified
, NORMAL_CACHE_ENTRY
,
783 header
, sizeof(header
), NULL
, NULL
))
786 if (strlenW(cache_path
) > dwBufLength
)
787 return E_OUTOFMEMORY
;
789 lstrcpyW(szFileName
, cache_path
);
794 /***********************************************************************
795 * HlinkSimpleNavigateToMoniker (URLMON.@)
797 HRESULT WINAPI
HlinkSimpleNavigateToMoniker(IMoniker
*pmkTarget
,
798 LPCWSTR szLocation
, LPCWSTR szTargetFrameName
, IUnknown
*pUnk
,
799 IBindCtx
*pbc
, IBindStatusCallback
*pbsc
, DWORD grfHLNF
, DWORD dwReserved
)
806 hres
= IMoniker_GetDisplayName(pmkTarget
, pbc
, 0, &target
);
808 hres
= HlinkSimpleNavigateToString( target
, szLocation
, szTargetFrameName
,
809 pUnk
, pbc
, pbsc
, grfHLNF
, dwReserved
);
810 CoTaskMemFree(target
);
815 /***********************************************************************
816 * HlinkSimpleNavigateToString (URLMON.@)
818 HRESULT WINAPI
HlinkSimpleNavigateToString( LPCWSTR szTarget
,
819 LPCWSTR szLocation
, LPCWSTR szTargetFrameName
, IUnknown
*pUnk
,
820 IBindCtx
*pbc
, IBindStatusCallback
*pbsc
, DWORD grfHLNF
, DWORD dwReserved
)
822 FIXME("%s %s %s %p %p %p %u %u partial stub\n", debugstr_w( szTarget
), debugstr_w( szLocation
),
823 debugstr_w( szTargetFrameName
), pUnk
, pbc
, pbsc
, grfHLNF
, dwReserved
);
825 /* undocumented: 0 means HLNF_OPENINNEWWINDOW*/
826 if (!grfHLNF
) grfHLNF
= HLNF_OPENINNEWWINDOW
;
828 if (grfHLNF
== HLNF_OPENINNEWWINDOW
)
830 SHELLEXECUTEINFOW sei
;
831 static const WCHAR openW
[] = { 'o', 'p', 'e', 'n', 0 };
833 memset(&sei
, 0, sizeof(sei
));
834 sei
.cbSize
= sizeof(sei
);
836 sei
.nShow
= SW_SHOWNORMAL
;
837 sei
.fMask
= SEE_MASK_FLAG_NO_UI
| SEE_MASK_NO_CONSOLE
;
838 sei
.lpFile
= szTarget
;
840 if (ShellExecuteExW(&sei
)) return S_OK
;
846 /***********************************************************************
847 * HlinkNavigateString (URLMON.@)
849 HRESULT WINAPI
HlinkNavigateString( IUnknown
*pUnk
, LPCWSTR szTarget
)
851 TRACE("%p %s\n", pUnk
, debugstr_w( szTarget
) );
852 return HlinkSimpleNavigateToString(
853 szTarget
, NULL
, NULL
, pUnk
, NULL
, NULL
, 0, 0 );
856 /***********************************************************************
857 * GetSoftwareUpdateInfo (URLMON.@)
859 HRESULT WINAPI
GetSoftwareUpdateInfo( LPCWSTR szDistUnit
, LPSOFTDISTINFO psdi
)
861 FIXME("%s %p\n", debugstr_w(szDistUnit
), psdi
);
865 /***********************************************************************
866 * AsyncInstallDistributionUnit (URLMON.@)
868 HRESULT WINAPI
AsyncInstallDistributionUnit( LPCWSTR szDistUnit
, LPCWSTR szTYPE
,
869 LPCWSTR szExt
, DWORD dwFileVersionMS
, DWORD dwFileVersionLS
,
870 LPCWSTR szURL
, IBindCtx
*pbc
, LPVOID pvReserved
, DWORD flags
)