To prove it, go to the Run command on your Start button and write the following:
|What You Need
|Windows 98 or later with IE 4 or later, Wscript, Rebol/View, and a text editor.
MSDN provides some good information about APPs, but be wary of what you read: You may come away with a misconception about what is required to achieve the most basic implementation of an APP under Windows. For example, one article implies that to write an APP one needs to implement certain interfaces, but APPs are actually very flexible. The basic implementation of an APP under Windows requires only that you make the proper entries in the registry for your protocol and that the handler for your protocol is a valid Windows .exe file. You can see an example at http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/pluggable/overview/appendix_a.asp. The “note” protocol defined in that example opens Notepad, similar to the way the view-source:// protocol can be used to open the .htm source of an HTML file in Notepad. For example, try putting this in your browser: view-source:http://www.devx.com.
I doubt that Notepad implements iinternetprotocol or any related interfaces, as to do so it should be a COM implementation and found at the following registry address HKEY_CLASSES_ROOTPROTOCOLS. Without these related interfaces, in the end all that happens is the protocol address is passed as a string via the command line to your application for analysis.
The W3C provides an incomplete list of addressing schemes, which you can use to search your system to see if these addressing schemes are implemented as APPs. Those that do more than just call over the command line should be found at the HKEY_CLASSES_ROOTPROTOCOLSHandler registry key.
There are many tools that allow you to dynamically load files via the command line, and pass on command lines to files. One example is script interpreters such as Wscript.exe. Here is the sample registry file, which shows how to set a simple WScript as the handler for a protocol called ws-proto.
Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOTws-proto]@=""URL: ws-proto Protocol"""URL Protocol"=""[HKEY_CLASSES_ROOTws-protoshell][HKEY_CLASSES_ROOTws-protoshellopen][HKEY_CLASSES_ROOTws-protoshellopencommand]@="wscript.exe c:\wsproto.js %1"
Here is the protocol that handles the WScript. (Both the registry file and the protocol handler are available in the code download for this article?see left column).
Why Rebol? Because Rebol is particularly good at handling protocols. By implementing a dynamic evaluating protocol in Rebol, I can very easily add functionality to interact with ftp, smtp, http, etc. (These protocols are easily accessible from Rebol using Rebol’s one-liner scripts, e.g. one line of code to read a URL and write the output to a local file.) Rebol can interact with any protocol that can be called via bookmarklet-type behavior, from a link on a web page, from writing in the address bar, from shortcuts, or from most any programming language/environment in the Windows system.
You can download a free, noncommercial version of Rebol from http://www.rebol.com/downloads/view-pro031.zip. It includes a Rebol dialect (sort of a DSL) for graphical interfaces, which I will use to implement a small form in my script. This form will help me decide, by showing the code passed to it, whether to evaluate the code, append it to a local file containing the script fragments I receive, or to edit it and then evaluate it.
It’s time to implement the Rebol script. There are links at various points to the Rebol function dictionary, which provides definitions of built-in Rebol functions to help you along. In the code download for this article there is a registry file called rebsettings.reg, which sets the reb protocol to be evaluated using a script called reb.r. Reb.r is the protocol handler that the registry files point at (see Listing 1). Install Rebol in the default installation folder c:
ebolview. Be advised that the Rebol installation program asks you for information such as your email address, email server etc., which it needs to send and receive mail and for the examples to work.
Once Rebol is installed, you should merge the accompanying .reg file and also install the files in the downloadable sample code (see link in left column) to the c:
ebolview directory. When you’ve done that, open the example.html file in your default browser. Listing 2 shows the contents of the example.html file.
- Callreb() takes a string parameter, which should be a reb:// link, and then uses the browser’s location.href method to navigate to the reb:// link.
- When executed in a link, browseloc() will tell Rebol to browse the page on which the link was executed.
The first link in the HTML page is:
Everything past the reb:// is legal Rebol code. And it does exactly what the link text tells you: It reads a local file, contained in the code download called oldfile.txt and writes a local file called newfile.txt. (Note that the parameters are intentionally opposite their function?this is because of the evaluation order of Rebol syntax). The % before the file names tells Rebol that these are in fact files. When you click on the link you should see something similar to Figure 2:
The popup is generated by Rebol’s built-in security (more information on controlling Rebol security settings). When you click Yes, reb.r loads (see Figure 3).
Pressing Do causes the Rebol interpreter to evaluate the text contained in the