Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to read the content of Internet Explorer's "Favourites" folder Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
29-Aug-02
Category
Shell API
Language
Delphi 2.x
Views
139
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: Tomas Rutkauskas

I would like to read the Properties of all entries in 'My Favorites' folder which 
contains all the web sites (URLs) addresses used by Internet Explorer. I would like 
to read the addresses and save them in a database. It's easier to do in Netscape 
because Netscape uses an HTML file that can be parsed easily.

Answer:

Solve 1:

The favourites folder is not very special. It just has some additions to the 
visibility. This function gets the location of it (no final backslash):

1   uses
2     ShlObj;
3   
4   function FavouritesPath: string;
5   var
6     FilePath: array[0..MAX_PATH] of char;
7   begin
8     SHGetSpecialFolderPath(0, FilePath, CSIDL_FAVORITES, false);
9     Result := FilePath;
10  end;


Then you can traverse this folder and search for all *.url files. This is done by 
FindFirst/ FindNext. Use a recursive procedure if you want the subfolders, too.

To get the shortcut from these files, you can use this function (BTW: This is how 
TIniFile reads a string):
11  
12  function GetInternetShortCut(const Filename: string): string;
13  var
14    Buffer: array[0..2047] of Char;
15  begin
16    SetString(Result, Buffer, GetPrivateProfileString('InternetShortcut',
17      PChar('URL'), nil, Buffer, SizeOf(Buffer), PChar(Filename)));
18  end;


Example:

GetInternetShortcut(FavouritesPath + '\OneOfMyFavourites.url')


Solve 2:

I'm not sure if SHGetSpecialFolderPath is available on all Win32 platforms. 
Alternatively, you can use:

11  
12  function GetInternetShortCut(const Filename: string): string;
13  var
14    Buffer: array[0..2047] of Char;
15  begin
16    SetString(Result, Buffer, GetPrivateProfileString('InternetShortcut',
17      PChar('URL'), nil, Buffer, SizeOf(Buffer), PChar(Filename)));
18  end;


Example:

GetInternetShortcut(FavouritesPath + '\OneOfMyFavourites.url')


Solve 2:

I'm not sure if SHGetSpecialFolderPath is available on all Win32 platforms. 
Alternatively, you can use:

function FavoritesPath: string;
var
  FilePath: array[0..MAX_PATH] of Char;
  IDL: PItemIDList;
begin
  Result := '';
  if Succeeded(SHGetSpecialFolderLocation(0, CSIDL_FAVORITES, IDL)) then
    if SHGetPathFromIDList(IDL, FilePath) then
      Result := FilePath;
end;

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC