2

注册表的方式

使用注册表的方式,通过注册表协议即可调用相应的桌面exe

  • 如在浏览器输入vscode:// ,回车之后即可出现如下的页面
    image.png

如何编写一个注册表

1.编写reg文件,定义注册表的协议及目标exe的文件位置
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\toy]
"URL Protocol"=""
@="URL:toy"

[HKEY_CLASSES_ROOT\toy\shell]

[HKEY_CLASSES_ROOT\toy\shell\open]

[HKEY_CLASSES_ROOT\toy\shell\open\command]
@="\"D:\\下载\\ChromeSetup.exe\" \"%1\""
2. 点击toy.reg,出现如下界面

image.png

3. 在注册表中查看

image.png

4. 浏览器中输入toy://, 出现image.png
5. 页面中调用
 const aLink = document.createElement('a');
 aLink.href = 'toy://startSession';
 document.body.append(aLink);
 setTimeout(() => {
   aLink.click();
   document.body.removeChild(aLink);
 }, 100);

坚果面包
21 声望0 粉丝