我在 Form1 中有这个按钮点击代码:
private void DriverVerifier_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Are you Sure you want to Launch the Driver Verifier. Click Yes to Confirm and No to continue", "WinForm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
}
else
{
ProcessRun.Processing(Environment.SystemDirectory, "verifier.exe", "", false, "");
}
}
这将运行Windows 7和8以及其他版本附带的驱动程序验证管理器程序。
问题出在某些用户的某些 Windows 版本中,当驱动程序验证程序管理器在表单后面运行并且您无法将其带到前面时。
我的问题是是否有任何方法可以强制这个过程位于前面?
这是我的 ProcessRun 类的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.IO;
namespace Diagnostic_Tool_Blue_Screen
{
static class ProcessRun
{
public static void Processing(string WorkingDirectory, string FileName, string Arguments, bool StandardOutput, string OutputFileName)
{
Process proc = new Process();
proc.EnableRaisingEvents = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = StandardOutput;
proc.StartInfo.FileName = FileName;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WorkingDirectory = WorkingDirectory;
proc.StartInfo.Arguments = Arguments;
proc.Start();
if (StandardOutput == true)
{
string output = proc.StandardOutput.ReadToEnd();
DumpOutput(WorkingDirectory + "\\" + OutputFileName, output);
}
proc.WaitForExit();
proc.Close();
}
private static void DumpOutput(string filename, string output)
{
StreamWriter w = new StreamWriter(filename);
w.Write(output);
w.Close();
}
}
}
这是程序在后台窗体后面时的样子的图像:
This is what a user with the problem wrote to describe the problem:
不过,在使用 Windows 8 和 Windows 8.1 时发现了一个错误,尚未使用 7 进行测试:驱动程序验证程序是相当无用的补充,因为当您单击它打开(底部的红色/棕色按钮)时,该工具的主窗口拒绝移动、最小化或关闭,保持焦点,因此无法看到“驱动程序验证程序”窗口,因为它仍然位于工具窗口下方(请参见屏幕截图)。
对于较大的显示器和多个显示系统,这只是一个小问题,因为驱动程序验证程序可以移到一边以便完全看到,但在较小的单显示系统上,它使该工具中的整个驱动程序验证程序毫无用处。