private static void Main(string[] args) { ShellApplication handler = new ShellApplication(); foreach (string arg in args) { switch (arg.ToLower()) { case "/shell": case "-shell": handler.InstallKeyboardHook(); break; case "/noicon": case "-noicon": break; case "/kill": case "-kill": TerminateProcess("mptray"); return; case "/register": case "-register": case "/register:user": case "-register:user": Register(true, Registry.CurrentUser); return; case "/register:all": case "-register:all": Register(true, Registry.LocalMachine); return; case "/unregister": case "-unregister": case "/unregister:user": case "-unregister:user": Register(false, Registry.CurrentUser); return; case "/unregister:all": case "-unregister:all": Register(false, Registry.LocalMachine); return; case "/unregister:both": case "-unregister:both": Register(false, Registry.CurrentUser); Register(false, Registry.LocalMachine); return; default: Log.Write("MPTray: Ignoring unknown command line parameter: '{0}'", arg); break; } } Process[] processes = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName); if (processes.Length != 1) { Log.Write("MPTray: Another instance of MPTray is already running"); return; } handler.Run(); }
private static void Main(string[] args) { ShellApplication handler = new ShellApplication(); foreach (string arg in args) { switch (arg.ToLowerInvariant()) { case "/shell": case "-shell": handler.InstallKeyboardHook(); break; case "/noicon": case "-noicon": break; case "/kill": case "-kill": TerminateProcess("mptray"); return; case "/register": case "-register": case "/register:user": case "-register:user": Register(true, Registry.CurrentUser); return; case "/register:all": case "-register:all": Register(true, Registry.LocalMachine); return; case "/unregister": case "-unregister": case "/unregister:user": case "-unregister:user": Register(false, Registry.CurrentUser); return; case "/unregister:all": case "-unregister:all": Register(false, Registry.LocalMachine); return; case "/unregister:both": case "-unregister:both": Register(false, Registry.CurrentUser); Register(false, Registry.LocalMachine); return; default: Log.Write("MPTray: Ignoring unknown command line parameter: '{0}'", arg); break; } } Process[] processes = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName); if (processes.Length != 1) { Log.Write("MPTray: Another instance of MPTray is already running"); return; } handler.Run(); }