Comments (6)
public static void RegisterOpenEvent(this RegistryKey source, string scheme, string appPath)
{
var index = scheme.IndexOf(":");
if (index == 0) throw new ArgumentException("无效的'scheme'", "scheme");
var key = index < 0 ? scheme : scheme.Substring(0, index);
var rootPath = source.CreateSubKey(key);
rootPath.SetValue(string.Empty, $"{ key }Protocol");
rootPath.SetValue("URL Protocol", appPath);
rootPath.CreateSubKey("DefaultIcon").SetValue(string.Empty, $"{ appPath },1");
var command = rootPath.CreateSubKey("shell").CreateSubKey("open").CreateSubKey("command");
command.SetValue(string.Empty, $"{ appPath } %1");
}
public static void UnRegisterOpenEvent(this RegistryKey source, string scheme)
{
var index = scheme.IndexOf(":");
if (index == 0) throw new ArgumentException("无效的'scheme'", "scheme");
var key = index < 0 ? scheme : scheme.Substring(0, index);
source.DeleteSubKeyTree(key, false);
}
from nanui.
大哥,你没理解问题含义呢,你的代码是“在注册表中注册URL Protocol协议”,而我说的问题是,如何在NanUI中,点击链接,并自动调用。这是两个问题,注册,根本不需要我自己写代码注册,因为一般客户端安装程序,本来就会自动注册,哪需要我自己注册呢?你注意看我上面说的一段话:“只要是系统中已安装的软件并支持web client app Protocol的软件,都能在NanUI调用”,问题是如何在NanUI调用
from nanui.
自定义的URL Protocol需要在注册表中注册, 这个是肯定的。至于这个工作是由哪里来做, 这个可以视情况而定。既然NanUI没有实现, 那么我们自己实现下也可以, 或者在制作安装包的时候把这块注册表添加上也可以。调用可以直接用a标签的href写, 如href="abc://123"
from nanui.
还是没说到重点啊,HTML链接代码<a href="search://">打开APP</a>,不用说,谁都会写的,问题是,点击后,NanUI如何处理这个事件,如何调用URL协议
from nanui.
CEF 的模型中在很多个环节上都提供了 CefRequest 对象,例如 BeforeBrowse 事件、GetResourceRequestHandler事件等等,那么捕获到浏览器的 Request,其中包括了请求的 URL 也就包含了目标的 Scheme,根据目标 Scheme 那么就可以开发相应的功能逻辑,要么交给系统(正如楼主的需求一样),要么自行处理。
from nanui.
写了段代码说明一下。
from nanui.
Related Issues (20)
- [问题] AutoShowMask 属性不存在。 HOT 1
- [BUG]fullscreen的时候,无法返回 HOT 1
- [问题] 什么时候支持linux arm64 HOT 1
- SendDataMessage 前端怎么接收消息[问题] HOT 1
- 希望添加网络拦截功能[REQUEST] HOT 1
- [问题]网页中运行的js有请求打开麦克风的功能,如何再NanUI下默认允许网页打开麦克风语音输入? HOT 1
- [问题]请教如何做exe单文件打包 HOT 1
- 请问在前端上传大文件或者大的请求json字符串应该使用哪种方式? HOT 1
- [问题]您当前的浏览器不支持 HTML5 播放器
- [REQUEST]能否允许在本地监听一个端口以便于前后端分离的开发模式(使前端可以更方便地进行调试) HOT 5
- [REQUEST] English docs HOT 2
- Layered模式下点击任务栏最小化程序后再点击窗体不显示[BUG] HOT 2
- 系统DPI不为100%时LayeredWindow图像丢失 HOT 1
- 太难了,老铁😂 HOT 10
- Add Docker HOT 2
- Embedding an ASP.NET Core Website Application with NanUI? HOT 2
- 文档都失效了吗? HOT 1
- Feature: Adding contribution section to the Readme.md file. HOT 2
- 无法找到libcef.dll文件路径或cef运行时文件结构不正确。
- Your applicaiton cannot run without the SubProcess. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nanui.