/**Retrieves a Process_Object to be stored. Stores name, PID, handle to process, and the actual Process object */ public static Process_Object GetProcessObject(string name) { Process_Object pb1 = new Process_Object(); Process[] tmp = Process.GetProcessesByName(name); // System.Console.Write(tmp.Length); if (tmp.Length == 0) { System.Console.Write("\nCouldn't find process\n"); return(null); } else if (tmp.Length == 1) { System.Console.Write("Found Exact Process"); pb1.SetProcess(tmp[0]); pb1.SetName(tmp[0].ProcessName); pb1.SetPID(tmp[0].Id); pb1.SetMWHandle(tmp[0].MainWindowHandle); //Get Handle after opening process, currently only containing Terminate_Process tag IntPtr tmp_hndle = WindowsStructs.OpenProcess((IntPtr)0x1F0FFF, false, (IntPtr)tmp[0].Id); if (tmp_hndle == null) { System.Console.Write("Could not open process"); pb1.SetHandle(tmp[0].Handle); } else { pb1.SetHandle(tmp_hndle); } //End getting of handle } else { System.Console.Write("Multiple Processes Found -- returning null"); return(null); } return(pb1); }