4

我想在 WebBrowser 完成浏览后清除 WebBrowser 控制历史记录。

4

2 回答 2

1

实际上,有两种类型的历史。一个是“已访问”页面列表,另一个是您在 IE 历史用户界面中看到的实际历史。

如果要删除访问过的页面列表,则需要使用 DeleteUrlCacheEntry 删除每个项目。通过使用 FindFirst/NextUrlCacheEntry API 循环,您可以访问创建这些项目的时间和日期,因此仅删除在浏览器会话开始之后和完成之前创建的项目。

对于 FindFirst/NextUrlCacheEntry 和 DeleteUrlCacheEntry 信息,网上有预先编写的代码可以使用,然后您可以轻松创建过滤器来决定在循环这些缓存条目时要删除哪些项目。

让我知道我是否可以提供进一步的帮助。

于 2012-08-31T11:19:29.990 回答
1

The history state of the System.Windows.Forms.WebBrowse control is internal and cannot be modified directly. All actions are performed via the GoBack and GoForward methods.

You can prevent your users from going backwards and forwards by setting the CanGoBack and CanGoForward properties to false. You would also want to modify the AllowWebBrowserDrop, WebBrowserShortcutsEnabled and IsWebBroserContextMenuEnabled properties as well.

Because history is only exposed through these methods, properties and user actions there is no need to clear the internal history state because the user cannot act on it. Note that session history (i.e. the back/forward buttons) is a separate concept from the "browser history" (what you see in the History panel in IE).

Note that it's possible that WebBrowser instances contained within other programs may write to the Windows user IE history files, however I don't know for certain. If they do I doubt there's anything you can do about that.

于 2012-08-31T01:48:54.810 回答