1 ///This function sets the display state of a window generated by a different thread2 /// </summary>3 /// <param name= "HWnd" >window Handle</param>4 /// <param name= "Cmdshow" >specifies how the window is displayed. To view a list of allowed values, consult the description section of the Showwlndow function</param>5 /// <returns>If the function is originally visible, the return value is not 0; if the function is originally hidden, the return value is zero</returns>6[DllImport ("User32.dll")]7 Private Static extern BOOLShowwindowasync (IntPtr hWnd,intcmdshow);8 /// <summary>9 ///The function creates a thread setting for the specified window to the foreground and activates the window. The keyboard input turns to the window and changes the various visual marks for the user. Ten ///the system assigns a slightly higher permission to the thread that creates the foreground window than the other threads. One /// </summary> A /// <param name= "HWnd" >window handle that will be activated and transferred to the foreground</param> - /// <returns>If the window is set to the foreground, the return value is not 0 and the return value is zero if the window is not set in the foreground</returns> -[DllImport ("User32.dll")] the Private Static extern BOOLSetForegroundWindow (IntPtr hWnd); - - Private voidBringToFront (IntPtr hWnd) - { + //Process currentprocess = process.getcurrentprocess (); - //Process process = Process.get (ID); + //if (process! = NULL) A //{ at //Showwindowasync (process. Mainwindowhandle, 1);//Show - //SetForegroundWindow (process. Mainwindowhandle);//when you go to the front - //} -process[] Processes = process.getprocesses ();//GetProcessesByName (currentprocess.processname); - foreach(Process processinchProcesses) - { in //process. Start (); - //if (process. Id! = currentprocess.id) to //{ + //if (assembly.getexecutingassembly (). Location.replace ("/", "\ \") - //<span style= "White-space:pre" > </span> = = currentProcess.MainModule.FileName) the // { * //return process; $ // }Panax Notoginseng if(Process. mainwindowhandle.tostring () = ="0") - { the Continue; + } A if(Process. Mainwindowhandle = =hWnd) the { +Showwindowasync (process. Mainwindowhandle,1);//Show -SetForegroundWindow (process. Mainwindowhandle);//when you go to the front $ } $ //} - } -}