• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 779
  • Last Modified:

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 ?
0
Tom_lyd
Asked:
Tom_lyd
  • 2
  • 2
1 Solution
 
jkrCommented:
>>when called from NT Service, the call enumPtr->Next will failed with uFetched=0, what's the problem ?

The problem is that 'LocalSystem' has no IE history. Services tun under a different account.
0
 
Tom_lydAuthor Commented:
Then How can I get the IE history in NT Service ?
0
 
jkrCommented:
Which user's history? As for the logged on user, you need to impersonate his/her security context before doing that.
0
 
Tom_lydAuthor Commented:
the current logged on user's IE history, how to do it ? how to impersonate his/her security context ?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now