How to clear browsing history using WebBrowser control in C#

后端 未结 2 1769
天命终不由人
天命终不由人 2020-12-22 12:52

I want to clear the browsing history of a WebBrowser control in C# after the WebBrowser completes its browsing.

This is my code:



        
2条回答
  •  生来不讨喜
    2020-12-22 13:37

    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.

    You will get 3 types of cache, on starting with "Cookie: ", another starting with "Visited: " - which just represents the visited sites list (it isn't the history, don't confuse the two), and the last type just comes in the form of a url begining with http:// or https://. Once you are looping through, you can pick and choose which ones you want to delete.

    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 created, 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.

提交回复
热议问题