【Reprint】Custom URL Protocol

Custom URL Protocol

Some applications can be launched automatically after clicking a url in the browser and perform an action. How is this achieved?
I googled a lot and found a blog to explain. Following these documents, I also tried it as a novice.

The executable program is invoked through the website, mainly to modify the registry and register the URL Protocol.
Step 1: Create a registry as shown below

Among them, [qiaoker] is built under the [HKEY_CLASSES_ROOT] primary key of the registry.
[qiaoker] This key can be customized arbitrarily.

Step 2: Create relevant key-value pairs in the registry.

 

 

Note that the value of the command item above is C:\Program Files (x86)\Qiaoker\updater.exe "%1", this "%1" is the parameter passed to updater.exe.
We will talk about how to use it later.

 

第三步:编写测试页面
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns="http://www.w3.org/1999/xhtml">
  <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  </head>
    <body>
        <div>
            <a href="qiaoker://cid:110&username:xxh">
            执行可执行文件
            </a>
        </div>
    </body>
< /html>

Description: QiaokerProtocol: is the protocol name registered in the registry.
   cid:110&username:xxh is the parameter passed to the executable program.
   The program receives the parameter data and parses the relevant information in the string by itself.

Other instructions:
 I use the registry generated by Inno Setup IDE, write the registry when the program is installed, and delete the relevant registry information when uninstalling.
 The code that Inno Setup writes to the registry is as follows:
 [Registry]
Root: HKCR; SubKey: QiaokerProtocol; ValueData: "Qiaoker Protocol"; ValueType: string; Flags: CreateValueIfDoesntExist UninsDeleteKey;
Root: HKCR; SubKey: QiaokerProtocol; ValueName: "URL Qiaoker Protocol"; Flags: CreateValueIfDoesntExist; ValueType: string;
Root: HKCR; SubKey: QiaokerProtocol\DefaultIcon; ValueData: E:\Client1VNSkia2\bin\debug\updater.exe; Flags: CreateValueIfDoesntExist; ValueType: string;
Root: HKCR; SubKey: QiaokerProtocol\shell\open\command; ValueData: "E:\Client1VNSkia2\bin\debug\updater.exe ""%1"""; Flags: CreateValueIfDoesntExist; ValueType: string;

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327086451&siteId=291194637