将焦点放在正在打开的应用程序上?

Set focus on the application being opened?

我正在从 winform 打开一个应用程序。我想在打开后专注于那个应用程序。目前,当我打开它时,它会在 winform 后面打开。有人知道如何让我开始吗?以下是我如何从表单中打开我的应用程序:

Process.Start("C:\myapplication.exe")
'set focus to that particular application or bring it in front of the winform application.

尝试在 class:

中的某处添加此声明
 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)