欢迎访问!
您的支持是我们不断前行的动力!

C# HandleHelper 通过名称、层级关系查找句柄,获得句柄窗口类名称

通过名称查找句柄,通过层级关系查找句柄,获得句柄窗口类名称

//FindWindow 从类名或窗口名中返回一个相匹配的顶层窗口的句柄
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

//GetWindow 返回指定窗口的句柄
[DllImport("user32.dll", EntryPoint = "GetWindow", SetLastError = true)]
public static extern IntPtr GetWindow(IntPtr hWnd, uint uCmd);
//同级别第一个
private const int GW_HWNDFIRST = 0;
//同级别最后一个
private const int GW_HWNDLAST = 1;
//同级别下一个
private const int GW_HWNDNEXT = 2;
//同级别上一个
private const int GW_HWNDPREV = 3;
//属主窗口
private const int GW_OWNER = 4;
//子窗口
private const int GW_CHILD = 5;
//Enabled popup window有效的弹出窗口
private const int GW_ENABLEDPOPUP = 6;

//GetClassName 检取指定窗口类的名称
[DllImport("user32.dll", EntryPoint = "GetClassName", CharSet = CharSet.Auto)]
public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);

//GetClassName 检取指定窗口的标题
[DllImport("user32.dll", EntryPoint = "GetWindowText", CharSet = CharSet.Auto)] 
public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
赞(1) 打赏
转载请注明出处,未注明出处不得转载,蜘蛛侠 » C# HandleHelper 通过名称、层级关系查找句柄,获得句柄窗口类名称
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!

 

蜘蛛侠,您身边的爬虫专家!

觉得文章有用就打赏一下文章作者吧

支付宝扫一扫打赏

微信扫一扫打赏