I want to clear WebBrowser control history after WebBrowser completes its browsing.
Actually, there are two types of history. One is "Visited" pages list, and the other is the actual history you see in IE's history user interface.
If you want to remove the visited pages list, you need to use DeleteUrlCacheEntry to delete each item. By looping through using FindFirst/NextUrlCacheEntry API's you can get access to the time and date these items were creates, and therefore only delete the items created after your browser session started and before it was finished.
For FindFirst/NextUrlCacheEntry and DeleteUrlCacheEntry information, there are pre-written codes online that you can use, and then it will be easy for you to create a filter to decide which items you want deleted when you are looping through these cache entries.
Let me know if I can be of further assistance.
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.