Fairy-HE 2017-12-09 12:30 采纳率: 20%
浏览 941
已结题

C#计算器的进程不能关闭

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

    private void button1_Click(object sender, EventArgs e)
    {
        process1.Start();
    }

    private void button2_Click(object sender, EventArgs e)
    {
        FileInfo file = new FileInfo(@"C:\Windows\System32\calc.exe");
        if (file.Exists)
        {
            Process proc = new Process();
            proc.StartInfo.FileName = file.FullName;
            proc.Start();
        }
    }

    private void button3_Click(object sender, EventArgs e)
    {
        Process[] cp;
        cp = Process.GetProcessesByName("calc");

        //cp = Process.GetProcessesByName("calc.exe");
        int i = cp.Length;
        foreach (Process instance in cp)
        {
            instance.Close();
        }
    }
}

}

有两个启动计算器的按钮,一个关闭所有计算器进程的按钮,关闭的按钮获取不到计算器的进程为什么呢

  • 写回答

5条回答 默认 最新

  • 用月光取暖 2017-12-09 13:26
    关注

    #include /*数学函数的定义*/
    #include /*屏幕操作函数*/
    #include /*I/O函数*/
    #include /*库函数*/
    #include /*变量长度参数表*/
    #include /*图形函数*/
    #include /*字符串函数*/
    #include /*字符操作函数*/
    #define UP 0x48 /*光标上移键*/
    #define DOWN 0x50 /*光标下移键*/
    #define LEFT 0x4b /*光标左移键*/
    #define RIGHT 0x4d /*光标右移键*/
    #define ENTER 0x0d /*回车键*/
    void rar; /全局变量,保存光标图象*/
    struct palettetype palette; /*使用调色板信息*/
    int GraphDriver; /* 图形设备驱动*/
    int GraphMode; /* 图形模式值*/
    int ErrorCode; /* 错误代码*/
    int MaxColors; /* 可用颜色的最大数值*/
    int MaxX, MaxY; /* 屏幕的最大分辨率*/
    double AspectRatio; /* 屏幕的像素比*/
    void drawboder(void); /*画边框函数*/
    void initialize(void); /*初始化函数*/
    void computer(void); /*计算器计算函数*/
    void changetextstyle(int font, int direction, int charsize); /*改变文本样式函数*/
    void mwindow(char header); /窗口函数*/
    int specialkey(void) ; /*获取特殊键函数*/
    int arrow(); /*设置箭头光标函数*/
    /*主函数*/
    int main()
    {

    评论

报告相同问题?

悬赏问题

  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置