Here, we will add the "aricc" protocol as an example.
I. First, write a program that supports the aricc ProtocolProgram. Let's use C # To write a sample program.
1. Create a Windows application.
2. Add a Textbox Control to the form.
3. Modify form. CSCodeAs follows:
Public Partial Class Form1: Form
{
Public String CMD;
Public Form1 ()
{
Initializecomponent ();
}
Private VoidForm1_load (ObjectSender, eventargs E)
{
Textbox1.text= This. CMD;
}
}
4. Modify the main entry function in program. CS.
Static Void Main ( String [] ARGs)
{
Application. enablevisualstyles ();
Application. setcompatibletextrenderingdefault ( False );
Form1 mainform = New Form1 ();
If (ARGs. Length > 0 )
{
Mainform. cmd = ARGs [ 0 ];
}
Application. Run (mainform );
}
PS: the above purpose is to allow the winform program to support command line parameters. To more intuitively see the test results, we display the received parameters in a textbox in the form load event. That's all.
Assume that the program we generated is aricc.exe. It will be used later.
2. register the custom protocol to be used in the registry. Here, we will add the "aricc" protocol as an example.
1. Add aricc under hkey_classes_root.
2. Modify the "(default)" key value under aricc to "url: custom protocol ". You can write this part on your own.
3. Add a key value "URL protocol" under aricc.
4. Create a new item "shell" under aricc"
5. Create an item "open" under shell"
6. Create a new item "command" under the open item"
7. Modify the default key value of the command item to "C: \ path \ aricc.exe" "% 1"
The custom protocol has been registered.
Iii. Test.
1. Open the inventory, input the following code, and save it as test.html.
< A Href = "Aricc: // testcommandline" > Click here to start the program </ A >
2. Double-click the preceding HTML file to open it in the browser.
3. Click the link on the page.
4. You find that the program you just wrote is running. The textbox displays "aricc: // testcommandline /"
To Xiaoshi: I hope it will help you. Hoho