从服务添加 URL 到 IE 缓存

Adding URL to IE cache from a service

我有一个服务需要添加URLs到登录用户的IE缓存

为了做到这一点,我首先使用 OpenProcessToken and call ImpersonateLoggedOnUser

获取用户的令牌

我尝试使用 2 种方法添加 URL

  1. 使用IUrlHistoryStg2 COM interface, and calling the AddUrlAndNotify方法
  2. 按以下方式使用 CommitUrlCacheEntryW CommitUrlCacheEntryW(urlToEnterWithPrefix, 0, ExpireTime, LastModifiedTime, URLHISTORY_CACHE_ENTRY | NORMAL_CACHE_ENTRY, NULL, 0, NULL, NULL);

当进程在登录用户下运行时,这两种方法都工作正常,但在本地系统下运行时失败

CommitUrlCacheEntryW 文档统计:

WinINet does not support server implementations. In addition, it should not be used from a service. For server implementations or services use Microsoft Windows HTTP Services (WinHTTP).

但是我在 WinHTTP 中找不到任何对应于 CommitUrlCacheEntryW

的方法

我需要帮助解决以下问题:

  1. 我可以使用服务中的 IUrlHistoryStg2 访问已登录用户的 url 历史记录吗?
  2. 如何使用服务中的 CommitUrlCacheEntryW 或更简洁的功能来访问已登录用户的 url 历史记录?
  3. 还有第三个选项我还没有使用吗?

在反转 CommitUrlCacheEntryW 后 API 我发现它检查

  • 如果当前线程正在模拟
  • 如果处理服务

如果任一检查为真,则存在错误代码 0x80070078

所以,我想通过服务无法实现