Tom_lyd
asked on
Get ie history failed in NT service with IUrlHistoryStg2 and IEnumSTATURL, help !!!
BOOL CIEHistory::GetHistory( CIEUrlList & list )
{
STATURL url;
CString strUrl;
ULONG uFetched;
IUrlHistoryStg2Ptr history;
IEnumSTATURLPtr enumPtr;
HRESULT hResult = CoCreateInstance( CLSID_CUrlHistory, NULL, CLSCTX_INPROC_SERVER, IID_IUrlHistoryStg2,(void* *)&history );
if(FAILED(hResult))
{
log_.Log( "CoCreateInstance(CLSID_CU rlHistory, NULL, CLSCTX_INPROC_SERVER, IID_IUrlHistoryStg2,(void* *)&history ) failed, ret:%u", hResult );
return false;
}
if(FAILED(history->EnumUrl s(&enumPtr )))
{
log_.Log( "EnumUrls failed" );
return false;
}
while(SUCCEEDED(hResult = enumPtr->Next(1,&url,&uFet ched)) ) //When called from NT Service, it doesn't do the work ???
{
log_.Log( "enumPtr->Netxt result:%08X, uFetched:%u", hResult, uFetched );
if(uFetched==0)
break;
list.AddTail(CIEUrl(url));
}
return true;
}
The code above can get the url list when called from normal win32 app, however, when called from NT Service, the call enumPtr->Next will failed with uFetched=0, what's the problem ?
{
STATURL url;
CString strUrl;
ULONG uFetched;
IUrlHistoryStg2Ptr history;
IEnumSTATURLPtr enumPtr;
HRESULT hResult = CoCreateInstance( CLSID_CUrlHistory, NULL, CLSCTX_INPROC_SERVER, IID_IUrlHistoryStg2,(void*
if(FAILED(hResult))
{
log_.Log( "CoCreateInstance(CLSID_CU
return false;
}
if(FAILED(history->EnumUrl
{
log_.Log( "EnumUrls failed" );
return false;
}
while(SUCCEEDED(hResult = enumPtr->Next(1,&url,&uFet
{
log_.Log( "enumPtr->Netxt result:%08X, uFetched:%u", hResult, uFetched );
if(uFetched==0)
break;
list.AddTail(CIEUrl(url));
}
return true;
}
The code above can get the url list when called from normal win32 app, however, when called from NT Service, the call enumPtr->Next will failed with uFetched=0, what's the problem ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Which user's history? As for the logged on user, you need to impersonate his/her security context before doing that.
ASKER
the current logged on user's IE history, how to do it ? how to impersonate his/her security context ?
ASKER