-4

I m a C# developer. I have two screen(monitor) and I use this line of code:

Process.Start(@"C:\Program Files\Windows Media Player\wmplayer.exe" , @"C:\advertise.mp4");

to start My Windows Media Player.My question is that how can chose my process to start on second screen(monitor)?

Mike
  • 850
  • 10
  • 33

3 Answers3

4

As Banana mentioned in the comments, an easy and effective way to detect a second screen would be to add a reference in your project to the System.Windows.Forms assembly and then utilize the static AllScreens property of the Screen class, which returns an array of Screen instances. The following is a code sample just getting the count, but you could also find out other information such as detecting which of them is currently considering the Primary monitor in the system.

// using System.Windows.Forms int screenCount = Screen.AllScreens.Length;

Kyle Burns
  • 1,164
  • 7
  • 16
0

Like Banana commented: Using the Screen class you will be able to use it's AllScreens property.

From there you are able to take out the desired screen you wish to use by index:

var screens = Screen.AllScreens;
var screen = screens[1];

If you are using more than 2 screens using the DeviceName could be the way to go:

var screen = screens.Single(x => x.DeviceName == "name of the monitor");

As stated by Kyle Burns in his answer:

you could also find out other information such as detecting which of them is currently considering the Primary monitor in the system

Edit:

Here is a solution on how to start a process on a different screen

Mike
  • 850
  • 10
  • 33
-1
var screens = Screen.AllScreens; 

var count = screens.length;

You can also iterate trough the screens

screens.ForEach(screen => {
    //do something with screen object
});
k1dev
  • 631
  • 5
  • 14