📄 umon.c
字号:
return res;
res = S_FALSE;
if(SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&urlPath))) {
int result = lstrcmpiW(urlPath, This->URLName);
CoTaskMemFree(urlPath);
if(result == 0)
res = S_OK;
}
IUnknown_Release(bind);
return res;
}
/******************************************************************************
* URLMoniker_Hash
******************************************************************************/
static HRESULT WINAPI URLMonikerImpl_Hash(IMoniker* iface,DWORD* pdwHash)
{
URLMonikerImpl *This = (URLMonikerImpl *)iface;
int h = 0,i,skip,len;
int off = 0;
LPOLESTR val;
TRACE("(%p,%p)\n",This,pdwHash);
if(!pdwHash)
return E_INVALIDARG;
val = This->URLName;
len = lstrlenW(val);
if(len < 16) {
for(i = len ; i > 0; i--) {
h = (h * 37) + val[off++];
}
}
else {
/* only sample some characters */
skip = len / 8;
for(i = len; i > 0; i -= skip, off += skip) {
h = (h * 39) + val[off];
}
}
*pdwHash = h;
return S_OK;
}
/******************************************************************************
* URLMoniker_IsRunning
******************************************************************************/
static HRESULT WINAPI URLMonikerImpl_IsRunning(IMoniker* iface,
IBindCtx* pbc,
IMoniker* pmkToLeft,
IMoniker* pmkNewlyRunning)
{
URLMonikerImpl *This = (URLMonikerImpl *)iface;
FIXME("(%p)->(%p,%p,%p): stub\n",This,pbc,pmkToLeft,pmkNewlyRunning);
return E_NOTIMPL;
}
/******************************************************************************
* URLMoniker_GetTimeOfLastChange
******************************************************************************/
static HRESULT WINAPI URLMonikerImpl_GetTimeOfLastChange(IMoniker* iface,
IBindCtx* pbc,
IMoniker* pmkToLeft,
FILETIME* pFileTime)
{
URLMonikerImpl *This = (URLMonikerImpl *)iface;
FIXME("(%p)->(%p,%p,%p): stub\n",This,pbc,pmkToLeft,pFileTime);
return E_NOTIMPL;
}
/******************************************************************************
* URLMoniker_Inverse
******************************************************************************/
static HRESULT WINAPI URLMonikerImpl_Inverse(IMoniker* iface,IMoniker** ppmk)
{
URLMonikerImpl *This = (URLMonikerImpl *)iface;
TRACE("(%p,%p)\n",This,ppmk);
return MK_E_NOINVERSE;
}
/******************************************************************************
* URLMoniker_CommonPrefixWith
******************************************************************************/
static HRESULT WINAPI URLMonikerImpl_CommonPrefixWith(IMoniker* iface,IMoniker* pmkOther,IMoniker** ppmkPrefix)
{
URLMonikerImpl *This = (URLMonikerImpl *)iface;
FIXME("(%p)->(%p,%p): stub\n",This,pmkOther,ppmkPrefix);
return E_NOTIMPL;
}
/******************************************************************************
* URLMoniker_RelativePathTo
******************************************************************************/
static HRESULT WINAPI URLMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppmkRelPath)
{
URLMonikerImpl *This = (URLMonikerImpl *)iface;
FIXME("(%p)->(%p,%p): stub\n",This,pmOther,ppmkRelPath);
return E_NOTIMPL;
}
/******************************************************************************
* URLMoniker_GetDisplayName
******************************************************************************/
static HRESULT WINAPI URLMonikerImpl_GetDisplayName(IMoniker* iface,
IBindCtx* pbc,
IMoniker* pmkToLeft,
LPOLESTR *ppszDisplayName)
{
URLMonikerImpl *This = (URLMonikerImpl *)iface;
int len;
TRACE("(%p,%p,%p,%p)\n",This,pbc,pmkToLeft,ppszDisplayName);
if(!ppszDisplayName)
return E_INVALIDARG;
/* FIXME: If this is a partial URL, try and get a URL moniker from SZ_URLCONTEXT in the bind context,
then look at pmkToLeft to try and complete the URL
*/
len = lstrlenW(This->URLName)+1;
*ppszDisplayName = CoTaskMemAlloc(len*sizeof(WCHAR));
if(!*ppszDisplayName)
return E_OUTOFMEMORY;
lstrcpyW(*ppszDisplayName, This->URLName);
return S_OK;
}
/******************************************************************************
* URLMoniker_ParseDisplayName
******************************************************************************/
static HRESULT WINAPI URLMonikerImpl_ParseDisplayName(IMoniker* iface,
IBindCtx* pbc,
IMoniker* pmkToLeft,
LPOLESTR pszDisplayName,
ULONG* pchEaten,
IMoniker** ppmkOut)
{
URLMonikerImpl *This = (URLMonikerImpl *)iface;
FIXME("(%p)->(%p,%p,%p,%p,%p): stub\n",This,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut);
return E_NOTIMPL;
}
/******************************************************************************
* URLMoniker_IsSystemMoniker
******************************************************************************/
static HRESULT WINAPI URLMonikerImpl_IsSystemMoniker(IMoniker* iface,DWORD* pwdMksys)
{
URLMonikerImpl *This = (URLMonikerImpl *)iface;
TRACE("(%p,%p)\n",This,pwdMksys);
if(!pwdMksys)
return E_INVALIDARG;
*pwdMksys = MKSYS_URLMONIKER;
return S_OK;
}
/********************************************************************************/
/* Virtual function table for the URLMonikerImpl class which include IPersist,*/
/* IPersistStream and IMoniker functions. */
static const IMonikerVtbl VT_URLMonikerImpl =
{
URLMonikerImpl_QueryInterface,
URLMonikerImpl_AddRef,
URLMonikerImpl_Release,
URLMonikerImpl_GetClassID,
URLMonikerImpl_IsDirty,
URLMonikerImpl_Load,
URLMonikerImpl_Save,
URLMonikerImpl_GetSizeMax,
URLMonikerImpl_BindToObject,
URLMonikerImpl_BindToStorage,
URLMonikerImpl_Reduce,
URLMonikerImpl_ComposeWith,
URLMonikerImpl_Enum,
URLMonikerImpl_IsEqual,
URLMonikerImpl_Hash,
URLMonikerImpl_IsRunning,
URLMonikerImpl_GetTimeOfLastChange,
URLMonikerImpl_Inverse,
URLMonikerImpl_CommonPrefixWith,
URLMonikerImpl_RelativePathTo,
URLMonikerImpl_GetDisplayName,
URLMonikerImpl_ParseDisplayName,
URLMonikerImpl_IsSystemMoniker
};
/******************************************************************************
* URLMoniker_Construct (local function)
*******************************************************************************/
static HRESULT URLMonikerImpl_Construct(URLMonikerImpl* This, LPCOLESTR lpszLeftURLName, LPCOLESTR lpszURLName)
{
HRESULT hres;
DWORD sizeStr = 0;
TRACE("(%p,%s,%s)\n",This,debugstr_w(lpszLeftURLName),debugstr_w(lpszURLName));
This->lpvtbl = &VT_URLMonikerImpl;
This->ref = 0;
This->URLName = HeapAlloc(GetProcessHeap(), 0, INTERNET_MAX_URL_LENGTH*sizeof(WCHAR));
if(lpszLeftURLName)
hres = CoInternetCombineUrl(lpszLeftURLName, lpszURLName, URL_FILE_USE_PATHURL,
This->URLName, INTERNET_MAX_URL_LENGTH, &sizeStr, 0);
else
hres = CoInternetParseUrl(lpszURLName, PARSE_CANONICALIZE, URL_FILE_USE_PATHURL,
This->URLName, INTERNET_MAX_URL_LENGTH, &sizeStr, 0);
if(FAILED(hres)) {
HeapFree(GetProcessHeap(), 0, This->URLName);
return hres;
}
URLMON_LockModule();
if(sizeStr != INTERNET_MAX_URL_LENGTH)
This->URLName = HeapReAlloc(GetProcessHeap(), 0, This->URLName, (sizeStr+1)*sizeof(WCHAR));
TRACE("URLName = %s\n", debugstr_w(This->URLName));
return S_OK;
}
/***********************************************************************
* CreateAsyncBindCtx (URLMON.@)
*/
HRESULT WINAPI CreateAsyncBindCtx(DWORD reserved, IBindStatusCallback *callback,
IEnumFORMATETC *format, IBindCtx **pbind)
{
TRACE("(%08x %p %p %p)\n", reserved, callback, format, pbind);
if(!callback)
return E_INVALIDARG;
return CreateAsyncBindCtxEx(NULL, 0, callback, format, pbind, 0);
}
/***********************************************************************
* CreateAsyncBindCtxEx (URLMON.@)
*
* Create an asynchronous bind context.
*/
HRESULT WINAPI CreateAsyncBindCtxEx(IBindCtx *ibind, DWORD options,
IBindStatusCallback *callback, IEnumFORMATETC *format, IBindCtx** pbind,
DWORD reserved)
{
HRESULT hres;
BIND_OPTS bindopts;
IBindCtx *bctx;
TRACE("(%p %08x %p %p %p %d)\n", ibind, options, callback, format, pbind, reserved);
if(!pbind)
return E_INVALIDARG;
if(options)
FIXME("not supported options %08x\n", options);
if(format)
FIXME("format is not supported\n");
if(reserved)
WARN("reserved=%d\n", reserved);
hres = CreateBindCtx(0, &bctx);
if(FAILED(hres))
return hres;
bindopts.cbStruct = sizeof(BIND_OPTS);
bindopts.grfFlags = BIND_MAYBOTHERUSER;
bindopts.grfMode = STGM_READWRITE | STGM_SHARE_EXCLUSIVE;
bindopts.dwTickCountDeadline = 0;
IBindCtx_SetBindOptions(bctx, &bindopts);
if(callback)
RegisterBindStatusCallback(bctx, callback, NULL, 0);
*pbind = bctx;
return S_OK;
}
/***********************************************************************
* CreateURLMonikerEx (URLMON.@)
*
* Create a url moniker.
*
* PARAMS
* pmkContext [I] Context
* szURL [I] Url to create the moniker for
* ppmk [O] Destination for created moniker.
* dwFlags [I] Flags.
*
* RETURNS
* Success: S_OK. ppmk contains the created IMoniker object.
* Failure: MK_E_SYNTAX if szURL is not a valid url, or
* E_OUTOFMEMORY if memory allocation fails.
*/
HRESULT WINAPI CreateURLMonikerEx(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk, DWORD dwFlags)
{
URLMonikerImpl *obj;
HRESULT hres;
LPOLESTR lefturl = NULL;
TRACE("(%p, %s, %p, %08x)\n", pmkContext, debugstr_w(szURL), ppmk, dwFlags);
if (dwFlags & URL_MK_UNIFORM) FIXME("ignoring flag URL_MK_UNIFORM\n");
if(!(obj = HeapAlloc(GetProcessHeap(), 0, sizeof(*obj))))
return E_OUTOFMEMORY;
if(pmkContext) {
IBindCtx* bind;
DWORD dwMksys = 0;
IMoniker_IsSystemMoniker(pmkContext, &dwMksys);
if(dwMksys == MKSYS_URLMONIKER && SUCCEEDED(CreateBindCtx(0, &bind))) {
IMoniker_GetDisplayName(pmkContext, bind, NULL, &lefturl);
TRACE("lefturl = %s\n", debugstr_w(lefturl));
IBindCtx_Release(bind);
}
}
hres = URLMonikerImpl_Construct(obj, lefturl, szURL);
CoTaskMemFree(lefturl);
if(SUCCEEDED(hres))
hres = URLMonikerImpl_QueryInterface((IMoniker*)obj, &IID_IMoniker, (void**)ppmk);
else
HeapFree(GetProcessHeap(), 0, obj);
return hres;
}
/**********************************************************************
* CreateURLMoniker (URLMON.@)
*
* Create a url moniker.
*
* PARAMS
* pmkContext [I] Context
* szURL [I] Url to create the moniker for
* ppmk [O] Destination for created moniker.
*
* RETURNS
* Success: S_OK. ppmk contains the created IMoniker object.
* Failure: MK_E_SYNTAX if szURL is not a valid url, or
* E_OUTOFMEMORY if memory allocation fails.
*/
HRESULT WINAPI CreateURLMoniker(IMoniker *pmkContext, LPCWSTR szURL, IMoniker **ppmk)
{
return CreateURLMonikerEx(pmkContext, szURL, ppmk, URL_MK_LEGACY);
}
/***********************************************************************
* CoInternetQueryInfo (URLMON.@)
*
* Retrieves information relevant to a specified URL
*
* RETURNS
* S_OK success
* S_FALSE buffer too small
* INET_E_QUERYOPTIONUNKNOWN invalid option
*
*/
HRESULT WINAPI CoInternetQueryInfo(LPCWSTR pwzUrl, QUERYOPTION QueryOption,
DWORD dwQueryFlags, LPVOID pvBuffer, DWORD cbBuffer, DWORD * pcbBuffer,
DWORD dwReserved)
{
FIXME("(%s, %x, %x, %p, %x, %p, %x): stub\n", debugstr_w(pwzUrl),
QueryOption, dwQueryFlags, pvBuffer, cbBuffer, pcbBuffer, dwReserved);
return S_OK;
}
/***********************************************************************
* IsAsyncMoniker (URLMON.@)
*/
HRESULT WINAPI IsAsyncMoniker(IMoniker *pmk)
{
IUnknown *am;
TRACE("(%p)\n", pmk);
if(!pmk)
return E_INVALIDARG;
if(SUCCEEDED(IMoniker_QueryInterface(pmk, &IID_IAsyncMoniker, (void**)&am))) {
IUnknown_Release(am);
return S_OK;
}
return S_FALSE;
}
/***********************************************************************
* BindAsyncMoniker (URLMON.@)
*
* Bind a bind status callback to an asynchronous URL Moniker.
*
* PARAMS
* pmk [I] Moniker object to bind status callback to
* grfOpt [I] Options, seems not used
* pbsc [I] Status callback to bind
* iidResult [I] Interface to return
* ppvResult [O] Resulting asynchronous moniker object
*
* RETURNS
* Success: S_OK.
* Failure: E_INVALIDARG, if any argument is invalid, or
* E_OUTOFMEMORY if memory allocation fails.
*/
HRESULT WINAPI BindAsyncMoniker(IMoniker *pmk, DWORD grfOpt, IBindStatusCallback *pbsc, REFIID iidResult, LPVOID *ppvResult)
{
LPBC pbc = NULL;
HRESULT hr = E_INVALIDARG;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -