Posted by webmaster Guido
In Reply to: Re: Bookmark manager in Delphi posted by DelphiLand Team
: ... we'll have a look at the *structure* of the different formats.
Internet Explorer Favorite (bookmark) files are text files with the extension .URL, and their structure
is as follows:
[DEFAULT]
BASEURL=htp://www.somesite.com/
[InternetShortcut]
URL=htp://www.somesite.com/
Modified=B02A7206CFFFB40123
IconFile=htp://www.somesite.com/favicon.ico
IconIndex=1
The URL field contains the address location of the page to load. The other fields are optional and not necessary for our purpose. The description of the bookmark is the name of the URL-file, minus its extension. Example: File: DelphiLand.url Contents of DelphiLand.url: [DEFAULT]
BASEURL=htp://www.festra.com/
[InternetShortcut]
URL=htp://www.festra.com/
Modified=B02A7206CFFFB40123
How to add all the IE bookmarks to a list? 1. Add the path and name of each bookmark URL-file to a temporary Delphi
stringlist, for example: slUrlFiles. Do a recursive search for these files, starting in the base directory of the "Favorites".
For some example source code, have a look at our article
Find files with FindFirst and FindNext.
2. Create a Delphi stringlist so save the bookmark descriptions and URLs, for example: slBookMarks.
3. For each URL-file that's in slUrlFiles:
a. Open the URL-file and extract the URL field to a string variable, for example: BMUrl.
b. Put the URL-file filename without its path and its extension in a string variable, for example:
BMDesc.
c. Combine BMDesc and BMUrl into one string, with a separator between the two values, and add this to
slBookMarks. For the separator, use a character combination that you never would use in a bookmark name,
for example "{{" or
something similar.
4. Save slBookMarks to a text file, or in a CSV file, or in a database table of your choice.
Debugging tip: If you want to see what the program does, use 2 listboxes instead of stringlists. That slows it down, but it's a lot easier to debug :) and once that everything works, you can use stringlists.
Next: the FireFox bookmarks format.
Related Articles and Replies
|