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 use plug-in Internet Protocols (without DLL's) 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
17-Jan-03
Category
Internet / Web
Language
Delphi 2.x
Views
164
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: Tomas Rutkauskas

Show how to make a plugin protocol which executes your program and can pass 
variables to your application (like mailto:, http:, telnet:, outlook:,...)

Answer:

After searching through the internet for a way to integrate my application into 
Internet Explorer in the form of a protocol I found 2 different ways that were 
documented and included delphi code:

myprotocol://
http://mynamespace//

However I was looking for a way which would look like this:

myprotocol:

Eventually I gave up, until I noticed that on 
http://messenger.yahoo.com/messenger/imv they used this to execute a chat window 
with the desired theme. So I decided to look in the registry (as with all previous 
work I had discovered that the relevant data, usually including CLSID's would be 
linked together in the registry) and I discovered something
incredibly simple yet effective. Rather than using a DLL and CLSID's they had 
simply added some keys and values to the HKEY_CLASSES_ROOT exactly the same way as 
you would if you were associating a file-type. However there were 2 abnormal values:

HKEY_CLASSES_ROOTymsgr (Default) was equal to "URL: YMessenger Protocol"
There was a blank string added as HKEY_CLASSES_ROOTymsgr "URL Protocol"

After changing the default value I found that it made no difference, so all you 
need to do is to add a blank string named "URL Protocol".

This type of protocol can take parameters, which are parsed as follows:
Lets say that our program is named c:\program.exe and our protocol is program: if 
you use program:minimize, this is parsed asif you entered the following at the 
commandline:

c:>program.exe program:minimize

therefore ParamStr(1) is equal to program:minimize

Now, if you are wondering what this has to do with myprotocol:// type protocols, 
then I think you dont quite understand what was written above. Despite the fact 
that our protocol program: does not end with //, does not mean that we can not use 
it in the same way, after all, program: does take parameters, therefore you can 
actually use myprotocol:// and simply ignore that prefix.

Heres some code to add your program as a protocol:
1   
2   procedure AddProtocol(Details, Protocol, Command: string);
3   var
4     Reg: TRegistry;
5   begin
6     Reg := TRegistry.Create;
7     Reg.RootKey := HKEY_CLASSES_ROOT;
8     Reg.LazyWrite := false;
9     Reg.OpenKey(Protocol, true);
10    Reg.WriteString('', Details);
11    Reg.WriteString('URL Protocol', '');
12    Reg.OpenKey('shell\open\command', true);
13    Reg.WriteString('', command);
14    Reg.CloseKey;
15    Reg.free;
16  end;
17  
18  //example
19  
20  AddProtocol('URL: DKB Protocol', 'dkb',
21    '"D:\Projects\Programs\DKB\Compiled\dkb.exe" %1');


			
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