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.
inva source
share