我正在将一个Linux应用程序移植到windows上,有两个可执行文件需要分别在主显示器和辅助显示器上启动。
在Linux中,它是通过#!/bin/sh脚本完成的,类似于
display_start_dualhead LVDS 800 480 DVI 1024 768 24导出screen_main=$LVDS导出screen_secondary=$DVI
如何在windows中启动监视器1中的exe1和监视器2中的exe 2?
发布于 2016-09-05 16:01:14
windows上的进程创建是通过传递STARTUPINFO结构的CreateProcess应用程序接口执行的。此结构允许将初始可见性和位置信息传递给启动的进程,以便该进程在创建和显示其初始窗口时使用此信息。
我不知道有没有内置的命令行工具可以用每个监视器的坐标填充位置字段,尽管可以指示start命令来最大化或最小化窗口。
尽管如此,创建一个枚举监视器并填充这些字段的应用程序应该是一项微不足道的工作。也就是说,这样做之后,您可能会发现应用程序忽略了这些字段,并直接定位它们的窗口。
发布于 2016-09-05 15:21:13
试试这个:
function void showOnMonitor1()
{
Screen[] sc;
sc = Screen.AllScreens;
//get all the screen width and heights
Form2 f = new Form2();
f.FormBorderStyle = FormBorderStyle.None;
f.Left = sc[0].Bounds.Width;
f.Top = sc[0].Bounds.Height;
f.StartPosition = FormStartPosition.Manual;
f.Location = sc[0].Bounds.Location;
Point p = new Point(sc[0].Bounds.Location.X, sc[0].Bounds.Location.Y);
f.Location = p;
f.WindowState = FormWindowState.Maximized;
f.Show();
}
function void showOnMonitor2()
{
Screen[] sc;
sc = Screen.AllScreens;
//get all the screen width and heights
Form2 f = new Form2();
f.FormBorderStyle = FormBorderStyle.None;
f.Left = sc[1].Bounds.Width;
f.Top = sc[1].Bounds.Height;
f.StartPosition = FormStartPosition.Manual;
f.Location = sc[1].Bounds.Location;
Point p = new Point(sc[1].Bounds.Location.X, sc[1].Bounds.Location.Y);
f.Location = p;
f.WindowState = FormWindowState.Maximized;
f.Show();
}或
if (System.Windows.Forms.SystemInformation.MonitorCount != 1)
{
Form form2 = new Form();
form2.Left = System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width + 1;
form2.Top = 0;
form2.ShowDialog();
}https://stackoverflow.com/questions/39325441
复制相似问题