111,080
社区成员




[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("User32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process[] _Process = System.Diagnostics.Process.GetProcessesByName("notepad"); //找到记事本的进程
if (_Process.Length != 0)
{
IntPtr _FormIntPtr = _Process[0].MainWindowHandle; //获取第1个记事本的窗体
ShowWindowAsync(_FormIntPtr, /*WS_SHOWNORMAL*/ 1);
SetForegroundWindow(_FormIntPtr);
}
}