Search code examples
c#wpfprocesscommand-line-argumentsapp-startup

Passing arguments to application


This question might seem a bit vague but here we go.

I am preventing multiple instances of my wpf application, like so:

Process proc = Process.GetCurrentProcess();
if (Process.GetProcessesByName(proc.ProcessName).Length > 1)
{
    Application.Current.Shutdown();
    return;
}

if (e.Args != null && e.Args.Count() > 0)
{
    this.Properties["Magnet"] = e.Args;
}

Is it possible to pass the command-line arguments to the application already running?


Solution

  • No, it is not possible. You should use some of inter process communication techniques.