1、新建一份txt,写入以下内容,其中 zyhtest 为自定义名字,exe路径记得改为自己本地exe的路径。然后将txt后缀改为reg,并双击运行。之后打开注册表可以在相应位置看到刚刚的内容。
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\zyhtest]
@="zyhtest"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\zyhtest\DefaultIcon]
@="F:\\Zyh\\vc++demo\\test_websocket\\Debug\\test_websocket.exe"
[HKEY_CLASSES_ROOT\zyhtest\shell]
[HKEY_CLASSES_ROOT\zyhtest\shell\open]
[HKEY_CLASSES_ROOT\zyhtest\shell\open\command]
@="F:\\Zyh\\vc++demo\\test_websocket\\Debug\\test_websocket.exe"
2、新建一份html,写入以下内容,zyhtest 记得改成自己的名称,并带上://
之后双击运行html,会弹出弹窗,点击即可运行自己的程序。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>open exe</title>
<style>
a{font-size: 30px;text-decoration: none;}
</style>
</head>
<script type="text/javascript">
function run(){
document.getElementById("autorun").click();
}
</script>
<body onload="run()">
<a href="zyhtest://"><span id="autorun"></span></a>
<hr/>
</body>
</html>