C#操作系统进程的源码演示

下边内容内容是关于C#操作系统进程的演示的内容。

 private bool CloseProcess(string CloseProcessName)
        {
            try
            {
                Process[] MyProcessS = Process.GetProcessesByName(CloseProcessName); 

                foreach (Process MyProcess in MyProcessS)
                {
                    MyProcess.Kill();
                    MyProcess.WaitForExit();
                    MyProcess.Close();
                    Thread.Sleep(10000);  
                }
            }
            catch (Exception)
            {
                return false;                                 
            }
            return true;                          
        }
        public bool StartProcess(string StartProPath)
        {
            try
            {
                Process TheStartProcess = Process.Start(StartProPath);            
            }
            catch (Exception)
            {
                return false;
            }

            return true;    
        }

猜你喜欢

转载自blog.51cto.com/14129678/2329536