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;    
        }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章