Maximize another process' Window in .NET

后端 未结 3 2411
粉色の甜心
粉色の甜心 2020-12-01 18:51

I have a handle on another process\' main window in .net (proc.MainWindowHandle). How do I maximize the window inside of .net?

3条回答
  •  余生分开走
    2020-12-01 18:56

    You can pinvoke to ShowWindow with SW_SHOWMAXIMIZED to maximize the window.

    Pinvoke.net has an entry for ShowWindow here.

    For example,

    // Pinvoke declaration for ShowWindow
    private const int SW_SHOWMAXIMIZED = 3;
    
    [DllImport("user32.dll")]
    static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
    
    // Sample usage
    ShowWindow(proc.MainWindowHandle, SW_SHOWMAXIMIZED);
    

提交回复
热议问题