public class IE
{
public IEnumerable<URL> GetHistory()
{
UrlHistoryWrapperClass urlHistory;
UrlHistoryWrapperClass.STATURLEnumerator enumerator;
List<STATURL> list = new List<STATURL>();
urlHistory = new UrlHistoryWrapperClass();
enumerator = urlHistory.GetEnumerator();
enumerator.GetUrlHistory(list);
List<URL> URLs = new List<URL>();
foreach (STATURL url in list)
{
string browser = "-- Internet Explorer";
bool containsBoth = url.URL.Contains("file:///");
if (url.Title != "" && containsBoth == false){
Console.WriteLine(String.Format("{0} {1} {2}", url.Title, url.URL, browser));
Thread.Sleep(500);
}
}
return URLs;
}
}
Here is the URL class:
public class URL
{
string url;
string title;
string browser;
public URL(string url, string title, string browser)
{
this.url = url;
this.title = title;
this.browser = browser;
}
}
Here is how you use this code:
- Go to the Codeproject page, and download the demo project. You may have to sign up for a free account. Now, open up the "UrlHistoryLibrary" project in Visual Studio and then build it. You should now have a "UrlHistoryLibrary.dll" file in /bin/debug.
- Now, create a new console project in Visual Studio. I use the 2010 Pro version.
- Right click the "References" folder, in the Solution Explorer, and choose the option to "Add Reference". Now, select the "Browse" folder and navigate into your "UrlHistoryLibrary/Bin/Debug" folder and select "UrlHistoryLibrary.dll".
- Now, in your references, add
using UrlHistoryLibrary; using System.Diagnostics; using System.Threading;
- Now, add the above IE class to your code. Right under that, outside of the IE class, add the URL class.
- Add a main class, or public static void Main(string[] args). Inside of that, include the following:
Process[] process_IE = Process.GetProcessesByName("iexplore"); if (process_IE.Length == 0) { IE ie = new IE(); ie.GetHistory(); } else Console.WriteLine("Sorry, IE is open. Please close IE and try again."); - Now, when you run your console program, you should get a list of History visited, in the format of Title, Url, Broswer.
A few notes:
- I have modified this a bit from the original code. I have made it so that the results will not display results with "file:///" in the url. It will also not display any empty titles.
- In the main function, I have added a check that will tell you if you have IE open, when you try to run. If so, it will give you an error message.
- I have added a 5 second delay between each URL.
Here is the complete tested source code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using UrlHistoryLibrary;
namespace BlogTestIE
{
class Program
{
static void Main(string[] args)
{
Process[] process_IE = Process.GetProcessesByName("iexplore");
if (process_IE.Length == 0)
{
IE ie = new IE();
ie.GetHistory();
}
else
Console.WriteLine("Sorry, IE is open. Please close IE and try again.");
}
}
public class IE
{
public IEnumerable GetHistory()
{
UrlHistoryWrapperClass urlHistory;
UrlHistoryWrapperClass.STATURLEnumerator enumerator;
List list = new List();
urlHistory = new UrlHistoryWrapperClass();
enumerator = urlHistory.GetEnumerator();
enumerator.GetUrlHistory(list);
List URLs = new List();
foreach (STATURL url in list)
{
string browser = "-- Internet Explorer";
bool containsBoth = url.URL.Contains("file:///");
if (url.Title != "" && containsBoth == false)
{
Console.WriteLine(String.Format("{0} {1} {2}", url.Title, url.URL, browser));
Thread.Sleep(500);
}
}
return URLs;
}
}
public class URL
{
string url;
string title;
string browser;
public URL(string url, string title, string browser)
{
this.url = url;
this.title = title;
this.browser = browser;
}
}
}
Great thoughts you got there, believe I may possibly try just some of it throughout my daily life.
ReplyDeleteMicrosoft Internet Explorer Support
sehr guter Beitrag
DeleteHow To Access Internet Explorer History In C >>>>> Download Now
Delete>>>>> Download Full
How To Access Internet Explorer History In C >>>>> Download LINK
>>>>> Download Now
How To Access Internet Explorer History In C >>>>> Download Full
>>>>> Download LINK Dy
Good one
ReplyDeleteI try to use it in visual web part and deploy it in sharepoint site
ReplyDeleteand i use windows server 2008 enterprise R2
visual studio 2010
error appear in
urlhistory=new UrlHistoryClass(); line.
SecurityException was unhandled by user code
System.security.Permission.SecurityPermission
Thanks
Hi. i try to run this code but its giving me error on the "url" word i.e.
ReplyDelete"Error :The type or namespace name 'URL' could not be found (are you missing a using directive or an assembly reference?)"
plz can u help me with this error its urgent...
Did you include the URL class I gave you?
DeleteHow To Access Internet Explorer History In C >>>>> Download Now
ReplyDelete>>>>> Download Full
How To Access Internet Explorer History In C >>>>> Download LINK
>>>>> Download Now
How To Access Internet Explorer History In C >>>>> Download Full
>>>>> Download LINK 3N