ole32: Use IMoniker::GetTimeOfLastChange to attempt to retrieve the last-modified time for the ROT entry.

However, fall back to CoFileTimeNow if it fails.
This commit is contained in:
Rob Shearman 2006-12-28 02:41:52 +00:00 committed by Alexandre Julliard
parent d4b755a834
commit 04498ba49a
1 changed files with 33 additions and 12 deletions

View File

@ -159,16 +159,21 @@ static HRESULT get_moniker_comparison_data(IMoniker *pMoniker, MInterfacePointer
return S_OK; return S_OK;
} }
static HRESULT reduce_moniker(IMoniker *pmk, IMoniker **pmkReduced) static HRESULT reduce_moniker(IMoniker *pmk, IBindCtx *pbc, IMoniker **pmkReduced)
{ {
IBindCtx *pbc; IBindCtx *pbcNew = NULL;
HRESULT hr = CreateBindCtx(0, &pbc); HRESULT hr;
if (FAILED(hr)) if (!pbc)
return hr; {
hr = CreateBindCtx(0, &pbcNew);
if (FAILED(hr))
return hr;
pbc = pbcNew;
}
hr = IMoniker_Reduce(pmk, pbc, MKRREDUCE_ALL, NULL, pmkReduced); hr = IMoniker_Reduce(pmk, pbc, MKRREDUCE_ALL, NULL, pmkReduced);
if (FAILED(hr)) if (FAILED(hr))
ERR("reducing moniker failed with error 0x%08x\n", hr); ERR("reducing moniker failed with error 0x%08x\n", hr);
IBindCtx_Release(pbc); if (pbcNew) IBindCtx_Release(pbcNew);
return hr; return hr;
} }
@ -292,6 +297,7 @@ RunningObjectTableImpl_Register(IRunningObjectTable* iface, DWORD grfFlags,
HRESULT hr = S_OK; HRESULT hr = S_OK;
IStream *pStream = NULL; IStream *pStream = NULL;
DWORD mshlflags; DWORD mshlflags;
IBindCtx *pbc;
TRACE("(%p,%d,%p,%p,%p)\n",This,grfFlags,punkObject,pmkObjectName,pdwRegister); TRACE("(%p,%d,%p,%p,%p)\n",This,grfFlags,punkObject,pmkObjectName,pdwRegister);
@ -308,8 +314,6 @@ RunningObjectTableImpl_Register(IRunningObjectTable* iface, DWORD grfFlags,
if (!rot_entry) if (!rot_entry)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
CoFileTimeNow(&rot_entry->last_modified);
/* marshal object */ /* marshal object */
hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream); hr = CreateStreamOnHGlobal(NULL, TRUE, &pStream);
if (hr != S_OK) if (hr != S_OK)
@ -342,13 +346,30 @@ RunningObjectTableImpl_Register(IRunningObjectTable* iface, DWORD grfFlags,
return hr; return hr;
} }
hr = reduce_moniker(pmkObjectName, &pmkObjectName); hr = CreateBindCtx(0, &pbc);
if (FAILED(hr)) if (FAILED(hr))
{ {
rot_entry_delete(rot_entry); rot_entry_delete(rot_entry);
return hr; return hr;
} }
hr = reduce_moniker(pmkObjectName, pbc, &pmkObjectName);
if (FAILED(hr))
{
rot_entry_delete(rot_entry);
IBindCtx_Release(pbc);
return hr;
}
hr = IMoniker_GetTimeOfLastChange(pmkObjectName, pbc, NULL,
&rot_entry->last_modified);
IBindCtx_Release(pbc);
if (FAILED(hr))
{
CoFileTimeNow(&rot_entry->last_modified);
hr = S_OK;
}
hr = get_moniker_comparison_data(pmkObjectName, hr = get_moniker_comparison_data(pmkObjectName,
&rot_entry->moniker_data); &rot_entry->moniker_data);
if (hr != S_OK) if (hr != S_OK)
@ -458,7 +479,7 @@ RunningObjectTableImpl_IsRunning( IRunningObjectTable* iface, IMoniker *pmkObjec
TRACE("(%p,%p)\n",This,pmkObjectName); TRACE("(%p,%p)\n",This,pmkObjectName);
hr = reduce_moniker(pmkObjectName, &pmkObjectName); hr = reduce_moniker(pmkObjectName, NULL, &pmkObjectName);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
hr = get_moniker_comparison_data(pmkObjectName, &moniker_data); hr = get_moniker_comparison_data(pmkObjectName, &moniker_data);
@ -509,7 +530,7 @@ RunningObjectTableImpl_GetObject( IRunningObjectTable* iface,
*ppunkObject = NULL; *ppunkObject = NULL;
hr = reduce_moniker(pmkObjectName, &pmkObjectName); hr = reduce_moniker(pmkObjectName, NULL, &pmkObjectName);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
hr = get_moniker_comparison_data(pmkObjectName, &moniker_data); hr = get_moniker_comparison_data(pmkObjectName, &moniker_data);
@ -602,7 +623,7 @@ RunningObjectTableImpl_GetTimeOfLastChange(IRunningObjectTable* iface,
if (pmkObjectName==NULL || pfiletime==NULL) if (pmkObjectName==NULL || pfiletime==NULL)
return E_INVALIDARG; return E_INVALIDARG;
hr = reduce_moniker(pmkObjectName, &pmkObjectName); hr = reduce_moniker(pmkObjectName, NULL, &pmkObjectName);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
hr = get_moniker_comparison_data(pmkObjectName, &moniker_data); hr = get_moniker_comparison_data(pmkObjectName, &moniker_data);