public static OpenProcess ( ProcessAccessFlags accessFlags, int processId ) : |
||
accessFlags | ProcessAccessFlags | The access level to the process object. |
processId | int | The identifier of the local process to be opened. |
Résultat |
public static SafeMemoryHandle OpenProcess(ProcessAccessFlags accessFlags, int processId)
{
// Get an handle from the remote process
var handle = NativeMethods.OpenProcess(accessFlags, false, processId);
// Check whether the handle is valid
if (!handle.IsInvalid && !handle.IsClosed)
return handle;
// Else the handle isn't valid, throws an exception
throw new Win32Exception(string.Format("Couldn't open the process {0}.", processId));
}