2

web页面集成调用第三方exe -- 编写注册表

 2 years ago
source link: https://segmentfault.com/a/1190000041105267
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

注册表的方式

使用注册表的方式,通过注册表协议即可调用相应的桌面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);

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK