例如:如果一个程序有警报,那么当该警报响起时会弹出另一个单独的程序?
答案 0 :(得分:0)
是的,您可以使用C#代码启动另一个程序。这是你如何做到的:
static void LaunchProgram()
{
// Path to program
const string ex2 = "C:\\Dir";
// Use ProcessStartInfo class
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
//File name of program to launch
startInfo.FileName = "program.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
// Log error.
}
}