How to Display all IE Mobile Favorites?

Let's say we want to write an application that displays all the favorites of IE Mobile and allows user to click them. Then IE Mobile should go to that URL.

We can certainly write some code to retrieve all the favorites items from \Windows\Favorites by calling FindFirstFile(). Note that some default favorites are saved in a registry key, so we might want to retrieve those as well. Then we can create a UI to show them, and then launch IE Mobile with the selected URL user clicked.

Or, we can utilize the default home page of IE Mobile, \windows\default_0409.htm. This page has some javascript that will call a window.external.favorites object which will retrieve all favorites into a string array. The javascript code looks like this:

    // Loads the current favorites
    function LoadFavorites()
    {  
        // favorites
        var favorites = window.external.favorites;
         
        for(var i = 0; i < favorites.length; ++i)
        {
             strFavHTML +=  "&nbsp;&nbsp;<a class=\"collection\" href='' onclick=\"window.external.favorites(" +
                            i + ").goTo();return false\">" + favorites(i).name +
                            "</a><br>";
        }  
                         
    }   

We can create a new page to do the same. However, when I copied the page onto the device and loaded it into IE Mobile, I did not see any favorites. What is the problem?

Security. The default home page default_0409.htm has a 'system' attribute! Okay, I changed my html file to be 'system' as well using Pocket Controller, then it worked!

Remaining work is quite simple. Write an application to call CreateProcess() and pass my own htm file name as parameter to IExplore.exe:

    SHELLEXECUTEINFO info;
    memset(&info, 0, sizeof(SHELLEXECUTEINFO));

    info.cbSize = sizeof(SHELLEXECUTEINFO);
    info.fMask = SEE_MASK_FLAG_NO_UI;
    info.lpVerb = _T ("open");
    info.lpFile = L"\\Windows\\IExplore.exe";
    info.lpParameters = L"file://\\windows\\fav.htm";
    info.nShow = SW_SHOW;
    ShellExecuteEx(&info);

My simple page fav.htm looks like this:

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  <meta name="MobileOptimized" content="240">
  <title>IE Mobile Favorites</title>

    <script>
    var strFavHTML   = "";
    var strHistHTML  = ""; 
    
    // Loads the current favorites
    function LoadFavorites()
    {  
        // favorites
        var favorites = window.external.favorites;
         
        for(var i = 0; i < favorites.length; ++i)
        {
             strFavHTML +=  "&nbsp;&nbsp;<a class=\"collection\" href='' onclick=\"window.external.favorites(" +
                            i + ").goTo();return false\">" + favorites(i).name +
                            "</a><br>";
        }  
                         
    }   
   
 
  </script>
</head>

<body align=center>
<p>My Favorites</p>

<script>
 LoadFavorites()
 document.write(strFavHTML);

</script>
 </body>
</html>