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;
|