从web启动winform程序

最近有个客户提出想从网站上启动一个客户端的程序,研究了下,实现方法如下:

1. 注入注册表

//create registry key for web launch
string appPath = """ + Application.ExecutablePath + "" "%1"";
string subKey = Application.ProductName + "\shell\open\command";
var newKey = Registry.ClassesRoot.CreateSubKey(subKey);
newKey.SetValue(null, appPath);

注入后效果如下图:

image

%1是传入的参数

2. 网站上加一个link

<a href="HelloWorld://123">Hello World</a>

这里123是传入的参数

image

当我们点击这个link时,就会自动打开这个客户端软件。

原文地址:https://www.cnblogs.com/jameslif/p/4101407.html