当前位置:网站首页>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.
边栏推荐
猜你喜欢
buuctf(探险2)
DP-Differential Privacy概念介绍
What are the benefits of enterprise data integration?How do different industries solve the problem of data access?
线性表的定义和基本操作
【kali-权限提升】(4.2.7)社会工程学工具包:权限维持创建后门、清除痕迹
加工制造业智慧采购系统解决方案:助力企业实现全流程采购一体化协同
ebook download | "Business executives' IT strategy guide - why enterprises should implement DevOps"
字节二面问的MySQL,差点没答好
buuctf (Adventure 2)
Haven't tried line art videos this year??
随机推荐
基于网络数据流的未知密码协议逆向分析
PyTorch框架的 torch.cat()函数
NetCore路由的Endpoint模式
智能家居设备安全分析技术综述
【kali-权限提升】(4.2.7)社会工程学工具包:权限维持创建后门、清除痕迹
shell之变量详解,让你秒懂!
IS31FL3737B general 12 x 12 LED drive 40 QFN I2C 42 ma
hdu 2647 Reward(拓扑排序)
Laravel之队列「建议收藏」
source install/setup.bash时出现错误
【图文并茂】如何进行Win7系统的重装
力扣15-三数之和——HashSet&双指针法
获取一段程序运行的时间
阿里二面:没有 accept,能建立 TCP 连接吗?
How are data integration APIs key to enterprise digital transformation?
字节二面问的MySQL,差点没答好
没有 accept,我可以建立 TCP 连接吗?
日期及时间处理包 Carbon 在 Laravel 中的简单使用[通俗易懂]
以技术创新加速国家“碳中和”建设进程,华为云创新中心助力欣冠精密实现云智控“气”
Why is the data of maxcompute garbled when imported into mysql?The table of mysql is the encoding of udf8mb4