1、创建注册表文件
创建xxx.reg注册表文件,内容如下(以打开Notepad++程序为例):
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\CHZ]
@="URL:CHZ自定义协议"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\CHZ\shell]
[HKEY_CLASSES_ROOT\CHZ\shell\open]
[HKEY_CLASSES_ROOT\CHZ\shell\open\command]
@="D:\\dev\\tools\\Notepad++\\notepad++.exe"
参数说明:
Windows Registry Editor Version 5.00:注册表的版本,
F1:私有协议的key;可自定义
@="URL:F1 Protocol Handler":指定对应协议类型
Shell:关键字
Open:动作
Command:要执行的命令
@="D:\\dev\\tools\\Notepad++\\notepad++.exe" :命令值
2、在html代码中添加私有协议链接
<a href="CHZ:www.gongstring.com">打开本地Notepad++程序</a>