コード例 #1
0
        public static int GetProcessIdFromHandle(Microsoft.Win32.SafeHandles.SafeProcessHandle processHandle)
        {
            Microsoft.Win32.NativeMethods.NtProcessBasicInfo info = new Microsoft.Win32.NativeMethods.NtProcessBasicInfo();
            int error = Microsoft.Win32.NativeMethods.NtQueryInformationProcess(processHandle, 0, info, Marshal.SizeOf(info), null);

            if (error != 0)
            {
                throw new InvalidOperationException(SR.GetString("CantGetProcessId"), new Win32Exception(error));
            }
            return(info.UniqueProcessId.ToInt32());
        }
 public static int GetProcessIdFromHandle(Microsoft.Win32.SafeHandles.SafeProcessHandle processHandle)
 {
     Microsoft.Win32.NativeMethods.NtProcessBasicInfo info = new Microsoft.Win32.NativeMethods.NtProcessBasicInfo();
     int error = Microsoft.Win32.NativeMethods.NtQueryInformationProcess(processHandle, 0, info, Marshal.SizeOf(info), null);
     if (error != 0)
     {
         throw new InvalidOperationException(SR.GetString("CantGetProcessId"), new Win32Exception(error));
     }
     return info.UniqueProcessId.ToInt32();
 }