Get control / form from IntPtr Handle

I am trying to get a managed control from the shown Word Application window using the following code:

Process[] processes = null;
processes = Process.GetProcessesByName("WINWORD");
Process wordProc = processes[0];
Control wordControl = Control.FromHandle(wordProc.MainWindowHandle);

Unfortunately, wordControl is always null ... as far as I know, FromHandle returns null if the control associated with the processing is not found. But in fact, I assume that there should be a related control, because I can see the window on my screen.

So my question is: if I am doing something terribly wrong, trying to get a handle or control. Or maybe my general approach will not work for some, currently unknown reasons, based somewhere in the .NET / Windows environment.

+3
source share
2 answers

, , . Word, , # WinForms Control - .

, , :

Edit

Word, , proc.

+1

Control.FromHandle , MainWindowHandle win32...

+1

All Articles