当前位置:网站首页>URL Protocol web page to open the application
URL Protocol web page to open the application
2022-08-09 22:07:00 【Calm Nine】
URL Protocol
Introduction
Sometimes when developing web pages, you will encounter a function that needs to open a computer-specific program. At this time, you need to use URL Protocol.
The general idea is to first register a custom URL Protocol for the application, and then use the URL Protocol to implement the web page to call the application.
1, add registry
Customize a registry file, similar to Protocol.reg, add the following
Windows Registry Editor Version 5.00[HKEY_CLASSES_ROOT\MyWinform]@="URL:MyWinform Protocol Handler""URL Protocol"=""[HKEY_CLASSES_ROOT\MyWinform\DefaultIcon]@="F:\\AllProjects\\VisualStudio\\TestWinform\\MyWinform\\MyWinform\\bin\\Debug\\MyWinform.exe"[HKEY_CLASSES_ROOT\MyWinform\shell][HKEY_CLASSES_ROOT\MyWinform\shell\open][HKEY_CLASSES_ROOT\MyWinform\shell\open\command]@="\"F:\\AllProjects\\VisualStudio\\TestWinform\\MyWinform\\MyWinform\\bin\\Debug\\MyWinform.exe\" \"%1\"""MyWinform" in the file is my custom program name, which can be changed to my own application name. Note that the path is double slashes.
2. Writing web pages
Write a simple web page here, which is mainly a hyperlink. The "MyWinform" at the beginning is the user-defined program name, and parameters can be passed later.
Click me to try it
Effects

3. Parameter reception
Here only describes how to accept parameters under Winform, others can study by themselves.
/// /// The main entry point for the application./// [STAThread]static void Main(string[] args){string inputArgs = string.Join(",", args);if (AnotherAppIsRunning()){MessageBox.Show("A program is already running: " + inputArgs);}else{MessageBox.Show(inputArgs);Console.WriteLine(inputArgs);Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(new Form1());Console.WriteLine("The game is officially started!!!!");}}Rendering

Summary
There are also some ways to add registry in C# script, but it requires administrator privileges. If necessary, you can learn about the RegistryKey class.
边栏推荐
- 力扣 899. 有序队列
- Haven't tried line art videos this year??
- mysql 重复数据 分组 多条最新的记录
- 6 g underwater channel modeling were summarized based on optical communication
- URL Protocol 网页打开应用程序
- 超多AI开发者等你来玩转,一起燃动昇腾AI创享日南京站!
- 真香|持一建证书央企可破格录取
- 字节一面:TCP 和 UDP 可以使用同一个端口吗?
- 新起之秀 DPU,正在掀起数据中心变革!
- hdu 2094 产生冠军(STL map || 拓扑 || STL set)
猜你喜欢
随机推荐
SqlServer 2016 安装相关问题
Redis 大的情况下,key 要如何处理?
Cholesterol-PEG-Thiol,CLS-PEG-SH,胆固醇-聚乙二醇-巯基用于改善溶解度
【随笔】致19期的小伙伴们
Toronto Research Chemicals盐酸乙环胺应用说明
阿里二面:没有 accept,能建立 TCP 连接吗?
获取一段程序运行的时间
安装多版本php(php5.6,php7.2)
倍福CX5120实现温度控制例程详细解析
C语言之实现倒置字符串的两种方法
IS31FL3737B 通用12×12 LED驱动器 I2C 42mA 40QFN
【NOI模拟赛】防AK题(生成函数,单位根,Pollard-Rho)
WPF中加载并使用图像资源
技术分享 | 接口自动化测试如何处理 Header cookie
hdu 2094 产生冠军(STL map || 拓扑 || STL set)
Haven't tried line art videos this year??
一千以内的水仙花数
laravel之phpunit单元测试
Week 8 Deep learning for object detection
华为云创新中心助力启泰智能 补齐中小模具企业数字化能力短板









