控制C#Win32的句柄 [英] Handle To Control c# win32
问题描述
嗨
我正在一个项目中尝试在另一个应用程序中获取控件的句柄.但是我不太了解 System.Windows.Forms.Control.FromChildHandle(handle)函数.我正在做的是获取主窗体的句柄,并希望将所有子句柄放入控件中.
我一直在网上寻找示例,但没有找到任何示例,msdn也未提供示例.
我的代码实际上可以编译,但是 System.Windows.Forms.Control.FromChildHandle 函数不会返回控件.
谢谢您.
Hi
I am working on a project in which I am trying to get the handle of a control in another application. However I don''t understand too well the System.Windows.Forms.Control.FromChildHandle(handle) function. What I''m doing is getting the handle of the main form and want to get all the childhandles into controls.
I have been looking online for examples but haven''t found any and the msdn doesn''t provide examples.
My code actually compiles, but the System.Windows.Forms.Control.FromChildHandle function does not return a control.
thank you
推荐答案
^ ]
根据文档Control.FromChildHandle
在父链上移动 up 并返回具有给定句柄的控件,如果找不到,则为null.
我正在尝试在另一个应用程序中获取控件的句柄
你必须研究
EnumWindows [ FindWindow [ FindWindowEx [ UIAutomation [
Control.FromChildHandle Method - MSDN entry[^]
According to the documentationControl.FromChildHandle
walks up the parent chain and returns the control with the given handle, null if not found.
I am trying to get the handle of a control in another application
you have to look into
EnumWindows[^]
FindWindow[^]
FindWindowEx[^]
Or
UIAutomation[^]
In short you won''t be able to get aForm
and any kind ofControl
object which represents a form/control in another application. ThusControl.FromChildHandle
returns null when you give it a handle that doesn''t belong to the current application.
这篇关于控制C#Win32的句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!