从web启动winform程序
发布时间:2020-12-13 20:12:22 所属栏目:PHP教程 来源:网络整理
导读:最近有个客户提出想从网站上启动1个客户真个程序,研究了下,实现方法以下: 1. 注入注册表 try { string appPath = Application.ExecutablePath %1 ; string strKey = Application.ProductName; string strKey_shell_open_cmd = strKey @shellopencommand ;
最近有个客户提出想从网站上启动1个客户真个程序,研究了下,实现方法以下: 1. 注入注册表 try
{
string appPath = """ + Application.ExecutablePath + "" "%1"";
string strKey = Application.ProductName;
string strKey_shell_open_cmd = strKey + @"shellopencommand";
var subKey = Registry.ClassesRoot.CreateSubKey(strKey);
subKey.SetValue("URL Protocol","1");
var subKey_shell_open_cmd = Registry.ClassesRoot.CreateSubKey(strKey_shell_open_cmd);
subKey_shell_open_cmd.SetValue(null,appPath);
}
catch (Exception ex)
{
MessageBox.Show(string.Format("Web启动参数设置失败,缘由: {0}",ex.Message));
}
注入后效果以下图: %1是传入的参数 2. 网站上加1个link <a href="HelloWorld://123">Hello World</a> 这里123是传入的参数 当我们点击这个link时,就会自动打开这个客户端软件。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |