码迷,mamicode.com
首页 > Web开发 > 详细

web打开exe程序

时间:2020-07-03 19:44:24      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:windows   链接   网页   index   注册   页面   表名   示例   version   

一、思路

如果想要web调用本地应用程序,可以通过自定义URL Protocol来调用应用程序。

浏览器在解析到自定义URL Protocol之后,会寻找注册表,然后通过注册表启动相应的程序。这样就可以在WEB页面调到你的程序了。比如在浏览器地址栏输入“tencent://message/?uin=88888888&Site=JooIT.com&Menu=yes”就会出现一个QQ对话框。

二、实现

1、新建.reg文件,并运行

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\注册表名]
"URL Protocol"="程序路径"
@="注册表名Protocol"
[HKEY_CLASSES_ROOT\注册表名\DefaultIcon]
@="程序路径,1"
[HKEY_CLASSES_ROOT\注册表名\shell]
[HKEY_CLASSES_ROOT\注册表名\shell\open]
[HKEY_CLASSES_ROOT\注册表名\shell\open\command]
@="\"程序路径\" \"%1\""

其中,@="\"程序路径\"  \"%1\"",此处的%1表示传入的参数,比如:tencent://message,解析后就可以得到参数message。

保存为.reg文件并运行。

2、web页面调用

在网页上可以直接通过一个超链接调用。

超链接格式:

协议://参数

3、示例

new.reg文件

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Imou]
"URL Protocol"="D:\\Software\\imou\\bin\\imou.exe"
@="ImouProtocol"
[HKEY_CLASSES_ROOT\Imou\DefaultIcon]
@="D:\\Software\\imou\\bin\\imou.exe,1"
[HKEY_CLASSES_ROOT\Imou\shell]
[HKEY_CLASSES_ROOT\Imou\shell\open]
[HKEY_CLASSES_ROOT\Imou\shell\open\command]
@="\"D:\\Software\\imou\\bin\\imou.exe\" \"%1\""

index.html文件

<html>
<body>
<a href="imou://">运行</a>
</body>
</html>

点击运行就会出现

技术图片

 

web打开exe程序

标签:windows   链接   网页   index   注册   页面   表名   示例   version   

原文地址:https://www.cnblogs.com/Jimc/p/13232106.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!