我正在从winform中打开一个应用程序。打开后我想专注于该应用程序。目前,当我打开它时,它会在winform后面打开。有谁知道如何让我入手?以下是我从表单中打开我的应用程序的方法:
Process.Start("C:\myapplication.exe")
'set focus to that particular application or bring it in front of the winform application.
答案 0 :(得分:0)
尝试在班级的某处添加此声明:
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As IntPtr
......并以这种方式开始这个过程:
Dim p As New System.Diagnostics.Process
p.StartInfo.FileName = "C:\myapplication.exe"
p.StartInfo.CreateNoWindow = False
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
p.Start()
SetForegroundWindow(p.Handle)