代码之家  ›  专栏  ›  技术社区  ›  jvn91173

在使用自定义URI方案时,如何将应用程序作为单独的实例启动?

  •  0
  • jvn91173  · 技术社区  · 5 年前

    我唯一担心的是,如果myapp的一个实例已经在运行,那么当我再次转到同一个URI时,该实例将被覆盖。我更希望创建一个新实例。有办法吗?

    我已经阅读了关于这个功能的文档 https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85)?redirectedfrom=MSDN

    HKEY_CLASSES_ROOT
       alert
          (Default) = "URL:Alert Protocol"
          URL Protocol = ""
          DefaultIcon
             (Default) = "alert.exe,1"
          shell
             open
                command
                   (Default) = "C:\Program Files\Alert\alert.exe" "%1"
    
    0 回复  |  直到 5 年前
        1
  •  1
  •   slacker    5 年前

    下面是一个示例应用程序:

    using System;
    
    namespace Alert
    {
      class Program
      {
        static void Main(string[] args)
        {
          Console.WriteLine("Command line: {0}", Environment.CommandLine);
          Console.WriteLine("Process Id: {0}", System.Diagnostics.Process.GetCurrentProcess().Id);
          Console.ReadLine();
        }
      }
    }
    

    Output of 3 invocations with the same uri