Etichetă: c# processes

Processes in C#

This article has been written before more than 24months, information might old.

Cateva functii pentru processe in c# :
1 Identificare Process dupa nume + redare id process
2 Functie bolean pt recunoasterea unui process dupa nume
3 Terminarea unui Process

Nota : nume process , si nume partial process trebuie schimbate cu stringuri adecvate .

1 :

public static int procidwga() {
            int procid = 0;
            Process[] allProcs = Process.GetProcesses();
            foreach (Process thisProc in allProcs)
            {
           
                string procName = thisProc.ProcessName;
                if (procName.Contains("nume partial process"))
                {
                procid =   Process.GetProcessesByName("nume process")[0].Id;

                return procid;

                }

            }
            return procid;

        }

2 :

        public static bool azproc()
        {
             
            
            Process[] allProcs = Process.GetProcesses();
            bool pulamea = false;
                foreach (Process thisProc in allProcs)
                {
                    string procName = thisProc.ProcessName;
                    if (procName.Contains("nume partial process"))
                    {
                        return pulamea = true;
                    }

                }
                return pulamea;
               
        }

3 :

  
      public static void azkillproc()
        {


            Process[] allProcs = Process.GetProcesses();
          foreach (Process thisProc in allProcs)
                {
                    string procName = thisProc.ProcessName;
                    if (procName.Contains("nume partial process"))
                    {
                        thisProc.Kill();


                    }
        
        }
        }