Link to home
Start Free TrialLog in
Avatar of Tom_lyd
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_CUrlHistory, NULL, CLSCTX_INPROC_SERVER, IID_IUrlHistoryStg2,(void**)&history) failed, ret:%u", hResult );
            return false;
      }
      if(FAILED(history->EnumUrls(&enumPtr)))
      {
            log_.Log( "EnumUrls failed" );
            return false;
      }
      while(SUCCEEDED(hResult = enumPtr->Next(1,&url,&uFetched)) ) //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 ?
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tom_lyd
Tom_lyd

ASKER

Then How can I get the IE history in NT Service ?
Which user's history? As for the logged on user, you need to impersonate his/her security context before doing that.
Avatar of Tom_lyd

ASKER

the current logged on user's IE history, how to do it ? how to impersonate his/her security context ?