Pages

Ads 468x60px

Friday, June 29, 2012

How to access Internet Explorer History in C#

So, you want to know how to access history for various browsers in C#? I found it very difficult to get it working correctly, so here is my top choices for Chrome, Firefox, and IE history code. Internet Explorer First off, here is IE. IE is, I think, the easiest history to be obtained. Browser history for IE is stored in the registry key of HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\TypedURLs. Now, Microsoft has published an interface on IUrlHistory, however that was not a C# wrapper. So, an article on CodeProject has a UrlHistoryLibrary.dll file which allows access to read and modify IE history.  The article shows how to to use the whole interface, however here is some prewritten code for returning IE history:
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:
  1. 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.
  2. Now, create a new console project in Visual Studio. I use the 2010 Pro version.
  3. 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". 
  4. Now, in your references, add 
    using UrlHistoryLibrary;
    using System.Diagnostics;
    using System.Threading;
  5. Now, add the above IE class to your code. Right under that, outside of the IE class, add the URL class.  
  6. 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.");
  7. 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;
        }
    }
}

Wednesday, June 20, 2012

Download and Convert Youtube videos to MP3 -- No Ads

I came across a very cool site, and it allows you to convert any Youtube video to Full Quality MP3 Files, that you can use with iTunes, WMP, or your MP3 Player. This site has no ads and it can even give you a button on a YouTube Video page to convert videos.

You can find this site here, and install the YouTube Firefox or Chrome extension here. Below is a video on how to get started:


Sunday, June 3, 2012

Download from Premium file hosting sites for free

This summary is not available. Please click here to view the post.

Unity 3d Multiplayer Video Tutorials

Unity3d is a game development software that has many features, including multiplayer capabilities and multiple programming languages.

Sometimes, however, it is very hard to get started making these games without an experienced guide. Over at Gamer To Game Developer website, that is what is happening. In series 1, he gets you started in making the base of a very professional multiplayer game, similar to Laser Tag, where each player has multiple weapons, and you must hit players of the other team. They are in YouTube format, and are from 10 minutes to 2 hours. Best of all, these videos are completely free. You can find them at the Gamer To Game Developer Website.

If you are looking to make a MMO type game, then head over to 3dbuzz.com. For only $35 a month, you get access to unlimited video tutorials for Blender, Unity, 3dsMax, and more. They have an all new MMO Developer class, where they walk you through every step of making your own MMO, using Unity3d game development software, and the Photon server backend. This is well worth the money.

SimCity 5 Release date announced

Recently, Maxis and EA have narrowed the release window for their new game, SimCity 5, to February of 2013. It is very surprising to find the date this early, seeing how they had a very generic "2013" date previously.