Call user32.dll to display other windows. Call the user32.dll window.
1 // This function sets the display status of Windows generated by different threads. 2 // </summary> 3 // <param name = "hWnd"> window handle </ param> 4 // <param name = "cmdShow"> specify how the window is displayed. To view the allowed value list, see description of the ShowWlndow function </param> 5 // <returns> if the function is visible, the returned value is non-zero. If the function is hidden, return Value: Zero </returns> 6 [DllImport ("User32.dll")] 7 private static extern bool ShowWindowAsync (IntPtr hWnd, int cmdShow ); 8 /// <summary> 9 // This function sets the thread that creates the specified window to the foreground and activates the window. Enter the keyboard to switch to the window and change various visual marks for the user. 10 // The system assigns a higher permission to the thread that creates the foreground window than other threads. 11 /// </summary> 12 /// <param name = "hWnd"> the window handle is activated and transferred to the foreground </param> 13 /// <returns> If the window is set to the foreground, the return value is non-zero. If the window is not set to the foreground, the return value is zero. </returns> 14 [DllImport ("User32.dll")] 15 private static extern bool SetForegroundWindow (IntPtr hWnd ); 16 17 private void BringToFront (IntPtr hWnd) 18 {19 // Process currentProcess = Process. getCurrentProcess (); 20 // Process process = Process. get (id); 21 // if (process! = Null) 22 // {23 // ShowWindowAsync (process. main1_whandle, 1); // display 24 // SetForegroundWindow (process. main1_whandle); // when it reaches the frontend 25 //} 26 Process [] Processes = Process. getProcesses (); // GetProcessesByName (currentProcess. processName); 27 foreach (Process process in Processes) 28 {29 // process. start (); 30 // if (process. id! = CurrentProcess. id) 31 // {32 // if (Assembly. getExecutingAssembly (). location. replace ("/", "\") 33 // <span> 34 // {35 // return process; 36 //} 37 if (process. main1_whandle. toString () = "0") 38 {39 continue; 40} 41 if (process. main1_whandle = hWnd) 42 {43 ShowWindowAsync (process. mainappswhandle, 1); // display 44 SetForegroundWindow (process. main1_whandle); // when arriving at the frontend 45} 46 //} 47} 48}