c# 中如何根据进程名获得指定的窗体在屏幕中Location

来源:百度知道 编辑:UC知道 时间:2024/06/02 00:48:43
如何根据进程名获得指定的窗体在屏幕中Location?注:不是本窗体的位置,是某个进程中的 某个窗体的位置。比如 打开一个notepad 获取它的Point ?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
using WINDOWINFO = WindowsFormsApplication1.tagWINDOWINFO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll", SetLastError = true)]
static extern bool GetWindowInfo(IntPtr hwnd, ref WINDOWINFO pwi);

private void button1_Click(object sender, EventArgs e)
{
Process [] ps = Process.GetProcessesByName("Config");
foreach (var p in ps)
{
IntPtr handle = p.MainWindowHandle;