• C#-进程-程序启动另一个进程.exe文件,关闭该进程


    沧海箫剑 

    一、启动

    string strPathExe = Environment.CurrentDirectory + "\FaceRecognition" + "\IDFaceDemo.exe";
    
    Process process = new System.Diagnostics.Process();
    process.StartInfo.FileName = strPathExe;
    process.StartInfo.Arguments = null;//-s -t 可以用来关机、开机或重启
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.RedirectStandardInput = false; //true
    process.StartInfo.RedirectStandardOutput = false; //true
    process.StartInfo.RedirectStandardError = false;
    process.StartInfo.CreateNoWindow = false;
    process.Start();//启动

    二、关闭

    方法1:

    process.CloseMainWindow();//通过向进程的主窗口发送关闭消息来关闭拥有用户界面的进程
    
    process.Close();//释放与此组件关联的所有资源

    方法2:手动关闭,退出

    process.WaitForExit();//等待退出。
  • 相关阅读:
    HDU ACM 1020 Encoding
    HDU ACM 1019 Least Common Multiple
    HDU ACM 1009 FatMouse' Trade
    HDU ACM 1032 The 3n + 1 problem
    HD ACM 1061 Rightmost Digit
    UVa 401 Palindromes
    UVa 489 Hangman Judge
    HDU ACM 1071 The area
    5/25
    受涼6/8
  • 原文地址:https://www.cnblogs.com/grj001/p/12223439.html
Copyright © 2020-2023  润新知