GlobalAccessSoftware icon

Program Main for 2nd Instance Messages to 1st.

GlobalAccessSoftware | PRO | 07/04/22 02:50:06 PM UTC | 0 ⭐ | 1333 👁️ | Never ⏰ | []
C# |

2.51 KB

|

None

|

0 👍

/

0 👎

//\\//\\//\\//\\//\\//\\//\\//\\//\\//
// Program.cs 02-Sep-2017
// 21-Feb-2018  MyEditor.Smesa
//\\//\\//\\//\\//\\//\\//\\//\\//\\//
// SMESAV Solution Started v1.0.1.00
// v1.0.1.02 02-Sep-2017
// v1.0.1.11 18-Oct-2017
// v1.1.2.26 12-Nov-2017 Solid Rocket
// v2.2.5.26 28-Dec-2017 Multi-Tabs
// v2.3.8.29 26-Jan-2018 Pass in Parms
// v2.5.9.30 04-Feb-2018 Release Tests
// v2.5.9.31 10-Feb-2018 Simplified.
// v2.6.0.32 15-Feb-2018 1351 Stocker
// v2.6.1.33 21-Feb-2018 1620 Mutexed
// v3.0.0.01 25-feb-2018 As WPF App.
// Experimental to pass args to an
// active 1st instance Smesa from a
// 2nd Instance Last Chance v3.0
// v3.0.0.37 28-Feb-2018 Hybrid.
// Working Model with hybrid strategy
// v3.1.1.38jamorama 07-Mar-2018 2332
//\\//\\//\\//\\//\\//\\//\\//\\//\\//
 
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Diagnostics;
using System.Windows.Forms;
 
using SMS = MyEditor.Properties.Settings;
using SMR = MyEditor.Properties.Resources;
 
namespace MyEditor
{
  static class Program
  {
    private static bool _1St;
    public static Mutex MyMutex =
      new Mutex(false, "Smesa", out _1St);
 
    private static bool ProcessCheck()
    {
      var processes =
        Process.GetProcessesByName(
          Process.GetCurrentProcess()
            .ProcessName).ToList();
      if (processes.Count > 1
        && SMS.Default.Testing)
        // testcode has not been seen so
        // far; as OpenWith isn't an Option.
          MessageBox.Show(SMR.ProcChck);
      return processes.Count < 2;
    }
 
    /// <summary> v3.1.1.38
    /// 04-Mar-2018 1715 MmfIpc Mods
    /// CopyRight (c) 2018 Jp Edwards
    /// </summary>
    [STAThread]
    static void Main()
    {
      if (_1St)
      {
        if (!ProcessCheck()) return;
        Application.EnableVisualStyles();
        Application
          .SetCompatibleTextRenderingDefault
          (false);
        Application.Run(
          new Smesa(Args(), Mmfn()));
        MyMutex.Dispose();
      }
      else Main2();
      // For ALL Secondary Instances.
    }
 
    private static void Main2()
    {
      Application.Run(
        new Smesa(Mmfn(), Args()));
    }
 
    private static string Mmfn()
    {
      var root = SMS.Default.AppRoot =
        Directory.GetCurrentDirectory();
      SMS.Default.Save();
      return root + "\\mmf.sme";
    }
 
    private static string[] Args()
    {
      return
        Environment.GetCommandLineArgs();
    }
 
 
  }
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎