之前在给客户做项目的时候,客户的需求是想通过前段HTML页面的按钮直接打开本地的应用,参考了资料,终于与解决了,话不多说,直接上源码。
方法:在客户端添加注册表,html通过<a href>跳转实现打开本地应用。
一个简单的小实例:
第一步:添加注册表
在桌面txt文件,后缀改为.reg
编辑文件
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Test]
"URL Protocol"="D:\\Thunder Network\Thunder9\Program\Thunder.exe"(这个是需要打开的应用,这是测试打开迅雷)
@="TestProtocol"
[HKEY_CLASSES_ROOT\Test\DefaultIcon]
@="D:\\Thunder Network\Thunder9\Program\Thunder.exe"(这个是需要打开的应用,这是测试打开迅雷)
[HKEY_CLASSES_ROOT\Test\shell]
[HKEY_CLASSES_ROOT\Test\shell\open]
[HKEY_CLASSES_ROOT\Test\shell\open\command]
@="D:\\Thunder Network\Thunder9\Program\Thunder.exe"(这个是需要打开的应用,这是测试打开迅雷)
下一步:
编辑完成后,双击运行文件
下一步:编辑html前台页面代码如下:
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta content="always" name="referrer">
<meta name="theme-color" content="#2932e1">
<title>openExe</title>
</head>
<body>
<a href="test://">openThunder</a>(test是注册表的名称)
</body>
</html>
欢迎各位留言讨论!