1. 程式人生 > >C#作業系統程序的原始碼演示

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;    
        }