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>