Internet Explorer-Detailed description of the custom address protocol (not reprinted)

Source: Internet
Author: User

Similar Problem: implement a download function similar to thunder. Click the download link. If Thunder is not installed, the thunder installation dialog box is displayed. If Thunder has been installed, it is required to start thunder, and download the desired seed.

Core Implementation: recently developed clientsProgramIs required to implement a custom IE Address Bar protocol, in order to achieve the effect of communicating with the client program by entering a string of compliant commands in the IE Address Bar. I have been thinking for a long time, and I checked the relevant information on the Internet. I found that all of them were copies, and the content was messy. So I want to write an article here for reference by other children's shoes, if you have any objection, just make a brick ~~ Haha

The functions I implemented here are mainly used to facilitate user communication with client programs through email, IE address connection, and other methods.

To implement the IE custom address protocol, you must first define the protocol in the registry. As follows:

Find the hkey_classes_root entry in the Registry and create a new entry. Here I name it idesk. This entry is the protocol entry. Next:

Create items according to the format. The data value in command is the entry address of the Startup Program. This is very important. This is the installation address of the program you want to communicate, then I will pasteCode:

///   <Summary>
/// Create a registry value
///   </Summary>
///   <Param name = "value"> Program path </Param>
Public   Static   Void Createregestartkey ( String Value)
{
Try
{
Registrykey key = Registry. classesroot;
Registrykey idesk = Key. createsubkey ( " Idesk " );
Idesk. setvalue ( "" , " URL protocol " );
Idesk. setvalue ( " URL protocol " , Value );
Registrykey defaulticon = Key. createsubkey ( " Idesk \ defaulticon " );
Defaulticon. setvalue ( "" , Value +   " , 0 " );
Registrykey command = Key. createsubkey ( " Idesk \ shell \ open \ command " );
Command. setvalue ( "" , String . Format ( " \ "{0} \", \ "% 1 \" " , Value ));
}
Catch (Exception ex)
{
Exceptionhandler. createexceptionlog (Ex );
}
}

With these registry items, it is easier to communicate with the client program below. These items need to be written into the registry when you install the client. If you do not want the 360 pop-up blocking window, you 'd better sign the application.

In the IE Address Bar, enter idesk: // www.baidu.com. At this time, ie will search for the Application address you set above and send messages to the application. The message format is: ", idesk: // www.baidu.com", the content in the quotation marks is the message content. Of course, if the security is high, you can encrypt the message.

So how does the client receive messages? I think this is relatively simple. We need to find it from the array of the entry function, that is, from static void main (string [] ARGs) in The args [] array, obtain and parse the protocol, and the task is OK.

Conclusion: implementing the above functions is actually very simple. Of course there are still a lot of follow-up work to be done. However, after refining the complicated problems and then breaking them apart, the problem becomes simple. Just like the question at the beginning, it is similar to implementing a thunder download function. When a user opens a website and wants to download something, click the link address. If the user does not install thunder, the browser will pop up the thunder download window, allowing users to download thunder (an ActiveX control implementation, to determine whether the user has installed thunder), otherwise the thunder will be opened through the Protocol, and send the link to the thunder program to download the seed, waiting for the user to click OK to download. It's not easy to implement this function after reading this article!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.