zoukankan      html  css  js  c++  java
  • 从web启动winform程序

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

    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));
                    }

    注入后效果如下图:

    image

    %1是传入的参数

    2. 网站上加一个link

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

    这里123是传入的参数

    image

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

  • 相关阅读:
    My Eclipse
    那一夜,我被梦中笑醒的事之(数据库)
    KTV项目总结
    欢迎来到,数据库联盟!
    学习手工创建表,表关系以及用exists 来查询
    sql 将Null 值转化成空字符串
    jquery toggle
    推荐一个不错的配色网站
    css之zindex
    关于前后端分离与不分离
  • 原文地址:https://www.cnblogs.com/fengwenit/p/4099227.html
Copyright © 2011-2022 走看看