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 ?
Tom_lydAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.