using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
using System.IO;
namespace CProcess
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnCalclaterStart_Click(object sender, EventArgs e)
{
CalculatorProcess.Start();
}
private void btnCalculatorStopAll_Click(object sender, EventArgs e)
{
Process[] CalculatorProcess;
CalculatorProcess = Process.GetProcessesByName("calc");
foreach (Process instance in CalculatorProcess)
{
instance.CloseMainWindow();
}
}
private void btnNotepadStart_Click(object sender, EventArgs e)
{
FileInfo finfo = new FileInfo(@"C:\WINDOWS\system32\calc.exe");
if (finfo.Exists)
{
Process prcNp = new Process();
prcNp.StartInfo.FileName = finfo.FullName;
prcNp.Start();
}
else
{
MessageBox.Show("文件:" + finfo.FullName + "不存在!");
}
}
private void btnNotepadStopAll_Click(object sender, EventArgs e)
{
Process[] prcNp;
prcNp = Process.GetProcessesByName("calc");
foreach (Process instance in prcNp)
{
instance.CloseMainWindow();
}
}
}
}
c#启动一个计算器进程
最新推荐文章于 2022-04-16 14:44:21 发布