#region display program [the DllImport ( " User32.dll " , the EntryPoint = " the FindWindow " )] public static extern int the FindWindow ( String the lpClassName, String lpWindowName); /// <Summary> /// This function sets produced by different threads It displays the status window. /// </ Summary> /// <param name = "the hWnd"> window handle </ param> /// <param name = "for ncmdshow"> Specifies how the display window. View list of allowed values, please refer to the Description section ShowWlndow function. </ param> /// <Returns></ Returns> [the DllImport ( " the User32.dll " )] Private static extern BOOL the ShowWindowAsync (IntPtr the hWnd, int for ncmdshow); /// <Summary> /// This function creates a thread set the specified window to the foreground, and activates the window. Steering the keyboard input window, and for the user to change various visual mark. Foreground window system to create a thread assigned permissions slightly higher than other threads. /// </ Summary> /// <param name = "the hWnd"> will be activated and transferred to the handle of the foreground window. </ param> /// <Returns> If the window is set into the front, the return value is zero; if the front window is not set, the return value is zero. </ Returns> [the DllImport ( " the User32.dll " extern bool SetForegroundWindow(IntPtr hWnd); private const int WS_SHOWNORMAL = 1; Process process = null; IntPtr appWin; [DllImport("user32.dll", SetLastError = true)] private static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent); [DllImport("user32.dll", SetLastError = true)] private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint); #endregion private void ToolStripMenuItem1_Click(object sender, EventArgs e) { foreach (Control c in pnlMain.Controls) { if (c.GetType().BaseType == typeof(Form)) { ((Form)c).Close(); } } try { string[] arrStr = IniData.VideoUrl.pathvalue.Split('.'); arrStr = arrStr[0].Split('\\'); string winName = arrStr[arrStr.Length - 1]; if (!string.IsNullOrEmpty(winName)) { int hWnd = FindWindow(winName, null); if (hWnd == 0) { //不存在 try { // Start the process process = System.Diagnostics.Process.Start(IniData.VideoUrl.pathvalue); // Wait for process to be created and enter idle condition process.WaitForInputIdle(); // Get the main handle appWin = process.MainWindowHandle; } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error"); } } else { P IntPtr = new new IntPtr (the hWnd); // presence of the SetForegroundWindow (P); the ShowWindowAsync (P, WS_SHOWNORMAL); // display the SetForegroundWindow (P); // put distal } } the else { AbstractPlugin.APluginDevice.ExportLog ( " video surveillance : program path configuration error " ); } } the catch { AbstractPlugin.APluginDevice.ExportLog (" Camera monitoring: program path configuration is incorrect. " ); } }