vb.net 如何使 vb 显示(最大化)另一个进程(窗口)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15456015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 12:50:04  来源:igfitidea点击:

How make vb to show ( maximize ) another process (window)

vb.net

提问by George Oprea

I have another program running and its process name is met2.exe. How can I get another program to maximize the met2.exeand keep it open in the start bar?

我正在运行另一个程序,它的进程名称是met2.exe. 如何让另一个程序最大化met2.exe并在开始栏中保持打开状态?

回答by volody

Try to use GetProcessesByName

尝试使用GetProcessesByName

Private Declare Function ShowWindow Lib "user32" (ByVal handle As IntPtr, ByVal nCmdShow As Integer) As Integer
Sub ShowAppWindow()
    Try
        Dim localByName As Process() = Process.GetProcessesByName("met2")
        For Each p As Process In localByName
            ShowWindow(p.MainWindowHandle, 3) ' SW_MAXIMIZE
        Next
    Catch ex As Exception
        ' do something
    End Try
End Sub