使用以下 C# 控制台应用程序代码,我可以使用 Jenkins 在后台运行该进程。但现在我想在前台看到这个过程。我在这里做错了什么?
[System.Runtime.InteropServices.DllImport("User32.dll")]
private static extern bool SetForegroundWindow(IntPtr handle);
[System.Runtime.InteropServices.DllImport("User32.dll")]
private static extern bool ShowWindow(IntPtr handle, int nCmdShow);
[System.Runtime.InteropServices.DllImport("User32.dll")]
private static extern bool IsIconic(IntPtr handle);
private void startT32app()
{
IntPtr handle;
try
{
Console.WriteLine("T32 launching");
string path = @"C:\T32\bin\windows64\t32mppc.exe";
string args = @"C:\T32\config.t32";
ProcessStartInfo procInfo = new ProcessStartInfo(path, args);
procInfo.CreateNoWindow = false;
procInfo.UseShellExecute = true;
procInfo.WindowStyle = ProcessWindowStyle.Normal;
Process procRun = Process.Start(procInfo);
handle = procRun.MainWindowHandle;
SetForegroundWindow(handle);
}
catch
{
Console.WriteLine("Failed to launch T32");
}
}
static void …Run Code Online (Sandbox Code Playgroud)