whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

35 Visitors Online


 
...get the Internet Explorer's favourites?
Autor: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch
[ Print tip ]  

Tip Rating (6):  
     


uses
  
ShlObj, ActiveX;

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;
  // Get all file names in the favourites path
  
path  := FavPath + '\*.url';
  dir   := ExtractFilepath(path);
  found := FindFirst(path, faAnyFile, searchrec);
  while found = 0 do
  begin
    
// Get now URLs from files in variable files
    
Setstring(FileName, Buffer, GetPrivateProfilestring('InternetShortcut',
      PChar('URL'), nil, Buffer, SizeOf(Buffer), PChar(dir + searchrec.Name)));
    str.Add(FileName);
    found := FindNext(searchrec);
  end;
  // find Subfolders
  
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);
  Result := str;
end;

procedure FreePidl(pidl: PItemIDList);
var
  
allocator: IMalloc;
begin
  if 
Succeeded(SHGetMalloc(allocator)) then
  begin
    
allocator.Free(pidl);
    {$IFDEF VER100}
    
allocator.Release;
    {$ENDIF}
  
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  
pidl: PItemIDList;
  FavPath: array[0..MAX_PATH] of Char;
begin
  if 
Succeeded(ShGetSpecialFolderLocation(Handle, CSIDL_FAVORITES, pidl)) then
  begin
    if 
ShGetPathfromIDList(pidl, FavPath) then
      
ListBox1.Items := GetIEFavourites(StrPas(FavPath));
    // The calling application is responsible for freeing the PItemIDList-pointer
    // with the Shell's IMalloc interface
    
FreePIDL(pidl);
  end;
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners