How to access a window?
问题 I'm trying to access a specific window using its handle (that is System.IntPtr value): // Getting the process of Visual Studio program var process = Process.GetProcessesByName("devenv")[0]; // Showing the handle we've got, we've no problem MessageBox.Show(this, process.MainWindowHandle.ToString()); // Attempting to get the main window object by its handle var wnd = NativeWindow.FromHandle(process.MainWindowHandle); // always fails if (wnd == null) MessageBox.Show("Failed"); else MessageBox