/// <summary> /// Opens a handle to a process /// </summary> /// <param name="process">The process-object of the process</param> /// <param name="flags">ProcessAccessFlags to use</param> /// <returns>A handle to the process</returns> public static IntPtr OpenHandleByProcess(Process process, WinAPI.ProcessAccessFlags flags) { return OpenHandleByProcessID(process.Id, flags); }
/// <summary> /// Opens a handle to a process /// </summary> /// <param name="name">Name of the process</param> /// <param name="flags">ProcessAccessFlags to use</param> /// <returns>A handle to the process</returns> public static IntPtr OpenHandleByProcessName(string name, WinAPI.ProcessAccessFlags flags) { return OpenHandleByProcessID(Process.GetProcessesByName(name)[0].Id, flags); }
/// <summary> /// Opens a handle to a process /// </summary> /// <param name="id">ID of the process</param> /// <param name="flags">ProcessAccessFlags to use</param> /// <returns>A handle to the process</returns> public static IntPtr OpenHandleByProcessID(int id, WinAPI.ProcessAccessFlags flags) { return WinAPI.OpenProcess(flags, false, id); }
/// <summary> /// Initializes a new ProcUtils /// </summary> /// <param name="process">Process-object of the process</param> /// <param name="handleFlags">ProcessAccessFlags to use</param> public ProcUtils(Process process, WinAPI.ProcessAccessFlags handleFlags) { Process = process; Handle = OpenHandleByProcess(process, handleFlags); }
/// <summary> /// Initializes a new ProcUtils /// </summary> /// <param name="id">ID of the process</param> /// <param name="handleFlags">ProcessAccessFlags to use</param> public ProcUtils(int id, WinAPI.ProcessAccessFlags handleFlags) : this(Process.GetProcessById(id), handleFlags) { }
/// <summary> /// Initializes a new ProcUtils /// </summary> /// <param name="processName">Name of the process</param> /// <param name="handleFlags">ProcessAccessFlags to use</param> public ProcUtils(string processName, WinAPI.ProcessAccessFlags handleFlags) : this(Process.GetProcessesByName(processName)[0], handleFlags) { }