当前位置:网站首页>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.
边栏推荐
猜你喜欢

基于SSM实现手机销售商城系统

明明加了唯一索引,为什么还是产生重复数据?

win10配置CenterNet环境

数据分散情况的统计图-盒须图

为什么数字钱包需要引入小程序生态

How are data integration APIs key to enterprise digital transformation?

力扣383-赎金信——哈希映射数组法

不经意传输协议OT

What are the benefits of enterprise data integration?How do different industries solve the problem of data access?

新起之秀 DPU,正在掀起数据中心变革!
随机推荐
Toronto Research Chemicals单羟基舒更葡糖钠说明书
如何在WPF中设置Grid ColumnDefinitions的样式
新起之秀 DPU,正在掀起数据中心变革!
SqlServer 2016 备份和还原
解决执行Command报错executable file not found in $PATH
DSPE-PEG-Silane,DSPE-PEG-SIL,磷脂-聚乙二醇-硅烷修饰二氧化硅颗粒用
这年头还不来尝试线稿图视频??
队列题目:用队列实现栈
请问一下flink cdc mysql source 报这种错怎么处理呢?我都设置了useSSL=f
Js查找字符串中出现最多次数的字母和单词
SqlServer 2016 安装相关问题
如何从800万数据中快速捞出自己想要的数据?
[] free column Android dynamic debugging GDB APP of safety
一图详解沃土云创计划高校教师参与全流程
Oracle 字段自增
laravel 中配置文件.env解读
mysql duplicate data group multiple latest records
一千以内的水仙花数
Acrel5000web能耗系统在某学院的应用-Susie 周
访问控制知识