IE & Delphi News Getting started EmbeddedWB IEAddress Url History IEFavorites APP IECache IE5Tools IESecurity UI-Less Parser HTMLEdit XML Parser IEDownload Toolbox Links

FavoritesMenu
FavoritesListview
FavoritesTreeview

Favorites

 

The two components FavoritesMenu and FavoritesListview demonstrates how to resolve url-files, lnk-files and channel shortcuts in the Favorites-folder and import them to your webbrowser application.



Finding Favorites folder:

There are several way to find the Favorites-folder. You can look it up in the registry:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

Favorites=<Favorites folder>

or use CSIDL_FAVORITES (shlobj.pas):

function TForm1.Favoritesfolder: string;
var
pidl: PItemIDList;
buf: array[0..MAX_PATH] of Char;
begin
 if
Succeeded(ShGetSpecialFolderLocation(Handle, CSIDL_FAVORITES, pidl))
 then begin
 
ShGetPathfromIDList(pidl, buf);
  Result := buf;
 end else Result:='';
coTaskMemFree(pidl);
end;


Resolv URL-files:

Urls in the favorites folder are stored in URL-files. the content of the URL-file may look like this:

[InternetShortcut]
URL=http://www.microsoft.com/
Modified=C02C38454F3ABF01B2

You can use inifiles-functions to retrieve the url from each .url-file in the favorites folder:

function ResolveUrl_Using_Inifiles(Filename: string): string;
var
 
ini: TiniFile;
begin
 
result := '';
 ini := TIniFile.create(fileName);
 try
 
result := ini.ReadString('InternetShortcut', 'URL', '');
 finally
 
ini.free;
 end;
end;

Microsoft recommand the use of IUniformResourceLocator, since the structure of the .url-files may change in the future. This interface is declared in intshcut.h and a translation to delphi is included in Favoritesmenu and FavoritesListView:

function ResolveUrl_Using_IntShCut(Filename: string): string;
var
IURL: IUniformResourceLocator;
PersistFile: IPersistfile;
FName: array[0..MAX_PATH] of WideChar;
p: Pchar;
begin
 if
Succeeded(CoCreateInstance(CLSID_InternetShortcut, nil,    CLSCTX_INPROC_SERVER, IID_IUniformResourceLocator, IURL))
 then begin
 
Persistfile := IUrl as IPersistFile;
  StringToWideChar(FileName, FName, MAX_PATH);
  PersistFile.Load(Fname, STGM_READ);
  IUrl.geturl(@P);
  Result := P;
 end;
end;

In FavoritesMenu and FavoritesListView you can use the property ResolveUrl to set the way you want urls to be resolved. 


Change Favorites folder:

You can change the location your webbrowser (and IE) will search for your favorites folder:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders

Favorites=<your new Path>

In IE5Tools is included a function SetFavoritesDirectory to change and restore favorites location.

Remove Favorites menu in IE:

If you do not want to have the favorites menu visible in IE you can remove in the registry:


HEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Restrictions

NoFavorites=1 (DWORD VALUE)


Set NoFavorites=0 then make the favorites menu visible again.

 

Links:

Q182034 - HOWTO- Invoke the "Add to Favorites" Dialog Box in IE4

Q172521 - Internet Explorer Truncates Favorites Names

Q257145 - Folders May Not Close in the Favorites Pane

Q255841 - Cannot Rename the Favorites Folder in Windows 2000

Q257011 - Cannot Rename Links Folder in Favorites

 

Created and maintained by
Per Lindsų Larsen

Last Update: Juli 27, 2000