I have the following function:
private void TakeOverAllScreens()
{
int i = 0;
foreach (Screen s in Screen.AllScreens)
{
if (s != Screen.PrimaryScreen)
{
i++;
Process.Start(Application.ExecutablePath, "Screen|" + s.Bounds.X + "|" + s.Bounds.Y + "|" + i);
}
}
}
As you can see it creates a separate instance of my application for each screen on the pc.
How can I create an exit function that closes all of them?
The function needs to work on any instance of the app, not just my “Main” instance.
You can terminate all processes with the same name: