• html(Angular) 调用本地安装exe程序


    1、写注册表

      新建 .reg文件

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOTcreoparametric]
    "URL Protocol"=""
    @="URL:creoparametric"
    
    [HKEY_CLASSES_ROOTcreoparametricshell]
    
    [HKEY_CLASSES_ROOTcreoparametricshellopen]
    
    [HKEY_CLASSES_ROOTcreoparametricshellopencommand]
    @=""D:\PTC\Creo 6.0.5.1\Parametric\bin\parametric.exe" "%1""

      保持并双击执行写入。

    2、调用

    url = 'creoparametric://'; //无参数
    url = 'creoparametric://param1&param2';  //带参数

      可以使用<a [href]="url"> 或者  window.open(url, '_blank', 'noopener'); 等方式调用

    3、测试服务端(c#),

      新建窗体程序

        static class Program
        {
            /// <summary>
            ///  The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main(string[] args)
            {
                Application.SetHighDpiMode(HighDpiMode.SystemAware);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1(args));
            }
        }

      Form

        public partial class Form1 : Form
        {
            string[] args;
            public Form1(string[] args)
            {
                this.args = args;
                InitializeComponent();
                LogHelper.Info("参数个数:" + args.Length.ToString());
                foreach (var a in args)
                {
                    LogHelper.Info("参数:" + a);
                    this.label1.Text += " " + a;
                }
    
            }
        }

      按照1和2,新建测试案例注册表:url='aaaamytest://'

    <a href="aaaamytest://param1&param2"> 

      进行测试后,日志:

    --------2021-04-29 10:23:42,435--------
    参数个数:1
    --------2021-04-29 10:23:42,443--------
    参数:aaaamytest://param1&param2/
  • 相关阅读:
    50道sql练习题和答案
    异步编程的数据同步
    浅说异步编程
    进程、应用程序域,线程和上下文之间的关系
    关于薪资和技术的一些思考
    SharePoint2013 列表栏设置
    SharePoint2013 功能区的配置
    EF Code First 数据迁移配置
    EF CodeFirst 数据库初始化策略
    用加减边距写图片轮播
  • 原文地址:https://www.cnblogs.com/wskxy/p/14717322.html
Copyright © 2020-2023  润新知