Ejemplo n.º 1
0
 private void Tools_ShowProcesses_Click(object sender, EventArgs e)
 {
     foreach (ProcessCE process in ProcessCE.GetProcesses())
     {
         Logger.Log("PID: " + process.handle.ToInt32() + " Name: " + process.processName);
     }
 }
Ejemplo n.º 2
0
        public static bool IsCalStarted()
        {
            bool found = false;

            foreach (ProcessCE process in ProcessCE.GetProcesses())
            {
                if (process.processName.ToLower() == "mcrscal.exe")
                {
                    found = true;
                    break;
                }
            }
            return(found);
        }
Ejemplo n.º 3
0
        public static ProcessCE[] GetProcesses()
        {
            //temp ArrayList
            ArrayList procList = new ArrayList();

            IntPtr handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

            if ((int)handle > 0)
            {
                try
                {
                    PROCESSENTRY32 peCurrent;
                    PROCESSENTRY32 pe32 = new PROCESSENTRY32();
                    //Get byte array to pass to the API calls
                    byte[] peBytes = pe32.ToByteArray();
                    //Get the first process
                    int retval = Process32First(handle, peBytes);
                    while (retval == 1)
                    {
                        //Convert bytes to the class
                        peCurrent = new PROCESSENTRY32(peBytes);
                        //New instance of the Process class
                        ProcessCE proc = new ProcessCE(new IntPtr((int)peCurrent.PID),
                                                       peCurrent.Name, (int)peCurrent.ThreadCount,
                                                       (int)peCurrent.BaseAddress);

                        procList.Add(proc);

                        retval = Process32Next(handle, peBytes);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Exception: " + ex.Message);
                }
                //Close handle
                CloseToolhelp32Snapshot(handle);

                return((ProcessCE[])procList.ToArray(typeof(ProcessCE)));
            }
            else
            {
                throw new Exception("Unable to create snapshot");
            }
        }
Ejemplo n.º 4
0
 public static void StopCAL()
 {
     Logger.Log("Stopping CAL...");
     foreach (ProcessCE process in ProcessCE.GetProcesses())
     {
         foreach (string calProcess in McrsCalProcesses)
         {
             if (calProcess.ToLower() == process.processName.ToLower())
             {
                 Logger.Log(process.processName + ": Killing...");
                 Process.GetProcessById(process.handle.ToInt32()).Kill();
                 Logger.Good(process.processName + ": Killed.");
                 break;
             }
         }
     }
     Logger.Good("CAL Stopped.");
 }