System.Diagnostics.Process.GetProcessHandle C# (CSharp) Method

GetProcessHandle() private method

Gets a short-term handle to the process, with the given access. If a handle exists, then it is reused. If the process has exited, it throws an exception.
private GetProcessHandle ( ) : SafeProcessHandle
return Microsoft.Win32.SafeHandles.SafeProcessHandle
        private SafeProcessHandle GetProcessHandle()
        {
            return GetProcessHandle(Interop.Advapi32.ProcessOptions.PROCESS_ALL_ACCESS);
        }

Same methods

Process::GetProcessHandle ( int access ) : SafeProcessHandle
Process::GetProcessHandle ( int access, bool throwIfExited ) : SafeProcessHandle

Usage Example

Esempio n. 1
0
 static SafeProcessHandle SafeGetHandle(Process process)
 {
     try
     {
         return(process.GetProcessHandle(Interop.Advapi32.ProcessOptions.PROCESS_QUERY_LIMITED_INFORMATION, false));
     }
     catch (Win32Exception)
     {
         return(SafeProcessHandle.InvalidHandle);
     }
 }