当前位置:网站首页>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.
边栏推荐
猜你喜欢
随机推荐
WPF中加载并使用图像资源
顺序表的定义和基本操作
matlab 神经网络 ANN 分类
继承关系下构造方法的访问特点
AttributeError: module ‘click‘ has no attribute ‘get_os_args‘
[Free column] Xposed plug-in development for Android security [from scratch] tutorial
mysql duplicate data group multiple latest records
渗透测试-对新型内存马webshell的研究
Why is the data of maxcompute garbled when imported into mysql?The table of mysql is the encoding of udf8mb4
Oracle 字段自增
pytest框架之mark标记功能详细介绍
听音识情绪 | 程序员手把手教你搭建神经网络,更快get女朋友情绪,求生欲max!
Prometheus Operator 自定义监控添加redis explorer
Queue topic: Implementing stacks with queues
【kali-密码攻击】(5.1.1)密码在线破解:Hydra(图形界面)
Laravel DB批量更新的方法
新起之秀 DPU,正在掀起数据中心变革!
【IoT毕设】STM32与机智云自助开发平台的宠物智能喂养系统
队列题目:用队列实现栈
【高效工具】远程控制软件 ToDesk(收藏夹)