admin管理员组文章数量:1664321
1. 需要启动的本地应用程序为:
e:\SRC\Test\MyApp\bin\Debug\MyApp.exe
2. 编辑注册表导入文件: MyApp_Disk_D.reg
内容如下:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\myapp]
@="URL:AutoHotKey myapp Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\myapp\DefaultIcon]
@="myapp.exe,1"
[HKEY_CLASSES_ROOT\myapp\shell]
[HKEY_CLASSES_ROOT\myapp\shell\open]
[HKEY_CLASSES_ROOT\myapp\shell\open\command]
@="\"e:\\SRC\\Test\\myapp\\bin\\Debug\\myapp.exe\" \"%1\""
4. 在IE中输入如下内容,即可启动应用程序myapp.exe
myapp://parameter
5. 至此在大多数浏览器中,已经能够通过自定义的协议启动指定应用程序了.
6. 对于Chrome浏览器,若不能启动指定的应用,请查看如下几点
6.1 自定义协议后的参数不能太短,最好超过三个字符,并且最好不要用一些常用的关键字.
6.2 配置Chrome的阻止的协议列表, 配置文件路径如下,不用的安装路径,还不用的用户,路径稍有不同:
C:\Users\liu\AppData\Local\Google\Chrome\User Data\Local State
打开此文件后,找到如下内容:
"protocol_handler":
{
"excluded_schemes":
{
"afp":true,
"data":true,
"disk":true,
"disks":true,
"file":true,
"hcp":true,
"iview":false,
"javascript":true,
"mailto":false,
"ms-help":true,
"ms-windows-store":false,
"myapp":false,
"news":false,
"nntp":true,
"shell":true,
"snews":false,
"tencent":false,
"vbscript":true,
"view-source":true,
确保我们自己定义的协议 myapp 后面的值为"false", 即不在被排除的列表中.
7. 通过网页中的连接打开本地相关应用程序的示例如下
<!DOCTYPE html>
<html>
<head>
<title>Web Automation</title>
<script type="text/javascript">
function dicom() {
var ret = confirm('Start Dicom Search?');
var aetitle = document.getElementById("txtAETitle").value;
var patientid = document.getElementById("txtPatientId").value;
var accessnumber = document.getElementById("txtAccessionNumber").value;
var local = document.getElementById("cbLocal").checked;
if (ret == true) {
window.location = 'myapp://,query,' + aetitle + ',' + patientid + ',' + accessnumber + ',' + local;
}
return;
};
function study() {
var ret = confirm('Open Study?');
var aetitle = document.getElementById("txtAETitle").value;
var studyInstanceUId = document.getElementById("txtStudyInstanceUId").value;
if (ret == true) {
window.location = 'myapp://,study,' + aetitle + ',' + studyInstanceUId;
}
return;
};
function LaunchApp() {
try {
var ret = confirm('Start myapp?');
if (ret == true) {
window.location = 'myapp://,start';
}
}
catch (ex) {
errMsg = "启动 myapp 报错.\n\n";
alert(errMsg);
}
return;
};
</script>
<style type="text/css">
#txtAccessionNumber
{
width: 191px;
}
#txtStudyInstanceUId
{
width: 901px;
}
</style>
</head>
<body>
<div>
<input type="button" value="Open IView" onclick = "LaunchApp()" /><br /><br />
<label>AE Title: <input id="txtAETitle" type="text" value="AETITLE" /></label>
<label>PatientID: <input id="txtPatientId" type="text" value="115042300003"/></label>
<label>AccessionNumber: <input id="txtAccessionNumber" type="text" /></label>
<label>Search Local:<input id="cbLocal" type="checkbox" value="local" /></label><br />
<label>StudyInstanceUId: <input id="txtStudyInstanceUId" type="text" value="1.2.392.200036.9125.2.138612190166.20150423000027"/></label><br /><br />
<input type="button" value="Dicom Search" onclick = "dicom()" /><br /><br />
<input type="button" value="Open study" onclick = "study()" />
</div>
</body>
</html>
版权声明:本文标题:自定义协议从浏览器中启动本地应用程序 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1730016061a1219255.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论