111,093
社区成员




public Form1()
{
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(Screen.PrimaryScreen.WorkingArea.Width + 100, 0);
}
private void button1_Clicked(object sender, EventArgs e)
{
var visualStudio = Process.GetProcessesByName("devenv").FirstOrDefault();
Rectangle rect = new Rectangle();
if (visualStudio != null && GetWindowRect(visualStudio.MainWindowHandle, ref rect))
{
MessageBox.Show("visual studio @" + rect);
}
}
[DllImport("User32")]
static extern bool GetWindowRect(IntPtr hWnd, ref Rectangle rect);
当然可能有多个Visual Studio在运行,也可能一个VS跨越好几个显示器。