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 add an url to Browser/Windows Favorite 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
23-Jun-03
Category
Internet / Web
Language
Delphi 2.x
Views
183
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: Arp Dev

How to add an url to Browser/Windows Favorite

Answer:

Note. I've made this example for complete beginner. 
Jump to the code if you don't need any explanation. There no API manipulation here, 
we place manually the shortcut in the the folder. 

Here's how you can add an url in you favorite. This work for any browser, except if 
they use special data type to store their url library. The only example I see of an 
application that use another type of data is the utility LinkMan wich is, anyway, 
not a browser application. 

Basicly, to create a shortcut url all you need to know is the structure of this 
file type. You need also to know a little about file manipulation, if you don't, 
this example will serve also as a guide for very simple file manipulation. 

First put 3 TEdit component on your form and add TButton component. 
Add three label to identify you EditBox. First EditBox should be associate with 
Folder, the second with URL and the last with Title. 

Folder -  Will store the access path to your browser favorite folder 
URL - Will store the URL (Http, www, etc) 
Title - Is the name you give to the URL (Yahoo, Baltsoft) 

For the AddUrl procedure to work, you need to pass it these three paramater as 
string. To do so affect your .Text property of your TEdit Component to your own 
variables. 

If you are new to Delphi you will find pretty interesting the output to file part 
where I use AssignFile, ReWrite, WriteLn... I suggest you try some of you own app 
using those command to test results with your own value.   

I included also a small line that can create a folder if the folder don't exist. 
This is a proper to the use of FileCtrl. Also of interest the small handling of \ 
if it's not present for lazy user. 

Don't change you components name, it will be easier to follow the code. 

Here we go.. 

1   unit MyUnit;
2   
3   interface
4   
5   uses
6     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 
7   StdCtrls,
8       FileCtrl;
9   
10  type
11    TForm1 = class(TForm)
12      Button1: TButton;
13      Edit1: TEdit;
14      Edit2: TEdit;
15      Edit3: TEdit;
16      procedure Button1Click(Sender: TObject);
17      procedure AddUrl(Folder, Url, Title: string);
18    end;
19  
20  var
21    Form1: TForm1;
22    MyFolder: string;
23    MyUrl: string;
24    MyTitle: string;
25  
26  implementation
27  
28  {$R *.DFM}
29  
30  procedure TForm1.Button1Click(Sender: TObject);
31  begin
32    MyFolder := Edit1.Text;
33    MyURL := Edit2.Text;
34    MyTitle := Edit3.Text;
35    AddUrl(MyFolder, MyUrl, MyTiTle);
36  end;
37  
38  procedure TForm1.AddURL(Folder, Url, Title: string);
39  var
40    MyUrlFile: TextFile;
41  begin
42    if Folder[Length(Folder)] <> '\' then
43      Folder := Folder + '\';
44    if not DirectoryExists(Folder) then
45      ForceDirectories(Folder);
46    try
47      AssignFile(MyUrlFile, Folder + title + '.url');
48      Rewrite(MyUrlFile);
49      WriteLn(MyUrlFile, '[InternetShortcut]');
50      WriteLn(MyUrlFile, 'URL=' + url);
51    finally
52      Closefile(MyUrlFile);
53    end;
54  end;
55  
56  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