我们基本上可以使用Windows API函数ShowWindowAsync方法来正常化/最大化/最小化另一应用程序

private void button1_Click(object sender, EventArgs e)
{
// 返回写字板程序的句柄
IntPtr hWnd = FindWindow("Notepad", "Untitled - Notepad");
if (!hWnd.Equals(IntPtr.Zero))
{
// SW_SHOWMAXIMIZED 最大化窗口
// SW_SHOWMINIMIZED 最小化窗口
// SW_SHOWNORMAL 是窗口正常大小
ShowWindowAsync(hWnd, SW_SHOWMAXIMIZED);
}
}

private const int SW_SHOWNORMAL = 1;
private const int SW_SHOWMINIMIZED = 2;
private const int SW_SHOWMAXIMIZED = 3;

[DllImport(
"user32.dll")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);

[DllImport(
"user32.dll")]
private static extern IntPtr FindWindow(string lpclassname, string lpwindowname);

相关文章:

  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
  • 2022-12-23
  • 2022-01-24
  • 2021-10-23
相关资源
相似解决方案