Get ie history failed in NT service with IUrlHistoryStg2 and IEnumSTATURL, help !!!

Posted on 2004-11-22
Last Modified: 2013-11-20
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 );
            log_.Log( "CoCreateInstance(CLSID_CUrlHistory, NULL, CLSCTX_INPROC_SERVER, IID_IUrlHistoryStg2,(void**)&history) failed, ret:%u", hResult );
            return false;
            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 );
      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 ?
Question by:Tom_lyd
    LVL 86

    Accepted Solution

    >>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.

    Author Comment

    Then How can I get the IE history in NT Service ?
    LVL 86

    Expert Comment

    Which user's history? As for the logged on user, you need to impersonate his/her security context before doing that.

    Author Comment

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

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
    If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now