C# FindWindowEx 查找窗体

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace ConsoleApp1
{
    class Program
    {

        [DllImport("user32.dll", EntryPoint = "FindWindowEx")]
        private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

        static void Main(string[] args)
        {
            IntPtr maindHwnd = FindWindowEx((IntPtr)0, (IntPtr)0,"窗体Class","窗体标题 也可以是null"); //获得句柄 
        }
    }
}

具体参数就不写了,到处都能搜到,做个笔记

posted @ 2022-09-27 20:03  鱼肉真好吃  阅读(355)  评论(0编辑  收藏  举报