.NET ez 2012-11-11
可以利用 Win32 API 控制 Console 視窗 最大化 或 最小化。
[DllImport("User32")] private static extern int ShowWindow(int hwnd, int nCmdShow); private enum CommandShow : int { SW_HIDE = 0, SW_SHOWNORMAL = 1, SW_NORMAL = 1, SW_SHOWMINIMIZED = 2, SW_SHOWMAXIMIZED = 3, SW_MAXIMIZE = 3, SW_SHOWNOACTIVATE = 4, SW_SHOW = 5, SW_MINIMIZE = 6, SW_SHOWMINNOACTIVE = 7, SW_SHOWNA = 8, SW_RESTORE = 9, SW_SHOWDEFAULT = 10, SW_FORCEMINIMIZE = 11, SW_MAX = 11 } ;
將 iexplore.exe 視窗最大化:
Process[] p = Process.GetProcessesByName("iexplore"); if (p.Length > 0) { for (int i = 0; i < p.Length; i++) { int hwnd = p[i].MainWindowHandle.ToInt32(); ShowWindow(hwnd, (int)CommandShow.SW_NORMAL); } } p = null;
標籤: .NET
本文章網址:
https://www.ez2o.com/Blog/Post/csharp-Change-App-Window-Size
https://www.ez2o.com/Blog/Post/295
https://www.ez2o.com/Blog/Post/csharp-Change-App-Window-Size
https://www.ez2o.com/Blog/Post/295