我有一项服务需要将 URL 添加到已登录用户的 IE 缓存中
为此,我首先使用 OpenProcessToken 获取用户的 token 并调用ImpersonateLoggedOnUser
我尝试用两种方法添加 URL
- 使用IUrlHistoryStg2 COM 接口(interface),并调用 AddUrlAndNotify方法
- 使用CommitUrlCacheEntryW通过以下方式
CommitUrlCacheEntryW(urlToEnterWithPrefix, 0, ExpireTime, LastModifiedTime, URLHISTORY_CACHE_ENTRY | NORMAL_CACHE_ENTRY, NULL, 0, NULL, NULL);
当进程在登录用户下运行时,这两种方法都工作正常,但在 LocalSystem 下运行时失败
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
我需要帮助解决以下问题:
- 我可以使用 IUrlHistoryStg2 吗?从服务访问登录用户的 url 历史记录?
- 如何使用 CommitUrlCacheEntryW还是服务中访问已登录用户的 url 历史记录的更简洁的功能?
- 是否还有第三个选项我还没有使用?
最佳答案
在逆向 CommitUrlCacheEntryW API 后我发现它检查
- 如果当前线程正在模拟
- 如果处理服务
如果任一检查为真,则存在错误代码 0x80070078
所以,我想通过服务无法实现
关于c++ - 从服务添加 URL 到 IE 缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36617266/