1. Home
  2. Computing & Technology
  3. Delphi Programming

Get IE favorites

By , About.com Guide

The GetIEFavourites function called from the OnClick event of a button returns a list of all the favorites from your Internet Explorer in a ListBox.

~~~~~~~~~~~~~~~~~~~~~~~~~
function GetIEFavourites
(const favpath: string):TStrings;
var
   searchrec:TSearchrec;
   str:TStrings;
   path,dir,filename:String;
   Buffer: array[0..2047] of Char;
   found:Integer;
begin
  str:=TStringList.Create;
  try
   path:=FavPath+'\*.url';
   dir:=ExtractFilepath(path) ;
   found:=FindFirst(path,faAnyFile,searchrec) ;
   while found=0 do begin
    SetString(filename, Buffer,
            GetPrivateProfileString('InternetShortcut',
            PChar('URL'), NIL, Buffer, SizeOf(Buffer),
            PChar(dir+searchrec.Name))) ;
    str.Add(filename) ;
    found:=FindNext(searchrec) ;
   end;
   found:=FindFirst(dir+'\*.*',faAnyFile,searchrec) ;
   while found=0 do begin
    if ((searchrec.Attr and faDirectory) > 0)
      and (searchrec.Name[1]<>'.') then
    str.AddStrings(GetIEFavourites
                 (dir+'\'+searchrec.name)) ;
    found:=FindNext(searchrec) ;
   end;
   FindClose(searchrec) ;
  finally
   Result:=str;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject) ;
var pidl: PItemIDList;
     FavPath: array[0..MAX_PATH] of char;
begin
  SHGetSpecialFolderLocation(Handle, CSIDL_FAVORITES, pidl) ;
  SHGetPathFromIDList(pidl, favpath) ;
  ListBox1.Items:=GetIEFavourites(StrPas(FavPath)) ;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Change glyphs of TDBNavigator Buttons
« List All Network Drives

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2001 Delphi Tips
  7. Get IE favorites

©2009 About.com, a part of The New York Times Company.

All rights reserved.