想要在网页调起本地的应用,需要在注册表里写入应用信息
gitee:https://gitee.com/zuiyuewentian/province-platform-tools
详细见代码:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace ProvincePlatformTools.Common
{
public static class RegisterTableHelper
{
///
/// 注册启动项到注册表
///
public static void Reg(string regName)
{
//注册的协议头,即在地址栏中的路径 如QQ的:tencent://xxxxx/xxx 例如:我注册的是jun 在地址栏中输入:jun:// 就能打开本程序
var surekamKey = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey(regName);
//以下这些参数都是固定的,不需要更改,直接复制过去
var shellKey = surekamKey.CreateSubKey("shell");
var openKey = shellKey.CreateSubKey("open");
var commandKey = openKey.CreateSubKey("command");
surekamKey.SetValue("URL Protocol", "");
//这里可执行文件取当前程序全路径,可根据需要修改
var exePath = Process.GetCurrentProcess().MainModule.FileName;
commandKey.SetValue("", "\"" + exePath + "\"" + " \"%1\"");
}
///
/// 取消注册
///
public static void UnReg(string regName)
{
//直接删除节点
Microsoft.Win32.Registry.ClassesRoot.DeleteSubKeyTree(regName);
}
}
}
调起的页面:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>官网</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div>
<a href="proplat://url=http://192.168.60.156:8199/zuigaofa-api-code/nei-html/index.html?czrname=九号球&ssbm=XXX&ssfy=0&lxdh=&courtName=XXXX&czrid=jhq&ajid=500000231"> 打开平台工具 </a>
</div>
</body>
</html>