Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Enumerating Internet Explorer's Favorites

0.00/5 (No votes)
9 Sep 2000 1  
An article on enumerating a users favorites list from Internet Explorer
  • Download source files - 24 Kb
  • Download demo project - 21 Kb
  • Introduction

    Recently I have been working on a project that involved getting the list of favorites (aka Bookmarks) in Internet Explorer. Microsoft does provide an API to dump all the favorites in a text file that follows Netscape's bookmark format. But that text file did not serve my purpose. First I needed a parser that could extract all the information from that file and secondly, the method call ImportExportFavorites on IShellUIHelper interface requires the user to select if they want to dump the favorites or not.

    This gave me a reason to search for alternatives. The answer was using the shell programming API. Favorites are stored in a user's profile as regular folders and files. Therefore I could use the file attributes to extract all the information that I needed, namely creation, modified and last access dates, URL, description of the favorite. During the search I came across a Microsoft article that described how to get started with this. With the help of that article and some of my own ideas I came up with this COM object, IFavoriteEngine, that does the trick for me.

    The implementation shows the use of the shell APIs and some COM concepts, and prepares the complete enumeration of Favorites on the system. This COM object has just two methods:

    LoadFavoritesThis method accesses all the Favorites on the system and prepares the enumeration list.
    GetFavoritesObjList</code<</td><td>This method returns the enumeration that was created by the <code>LoadFavorites method call.

    GetFavoritesObjList returns another COM object IFavoritesObjList. This object has its own methods that can be called to extract all the information. This object returns another COM object IFavoriteObject. This is the object that contains the details e.g. dates, description, etc.

    The SHGetSpecialFolderLocation API is used to get the list of all the favorites in a user's profile. The second parameter to this call is CSIDL_FAVORITES, indicating that it should fetch all the Favorites from a user profile. To get the other attributes of the favorites file and folders, the Win32 API GetFileAttributesEx has been used.

    I have included a simple Win32 console application to show how the IFavoritesEngine COM object can be used to get all the favorites on a system. The code has been written and compiled using VC++6 (SP4) on Windows 2000, Adv Server (SP1). I have only been testing the debug build. So if you find any problems with release configuration of the project, pleas e let me know.

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here