当前位置: 首页>>代码示例>>C#>>正文


C# SafeHandles.SafeProcessHandle类代码示例

本文整理汇总了C#中Microsoft.Win32.SafeHandles.SafeProcessHandle的典型用法代码示例。如果您正苦于以下问题:C# SafeProcessHandle类的具体用法?C# SafeProcessHandle怎么用?C# SafeProcessHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SafeProcessHandle类属于Microsoft.Win32.SafeHandles命名空间,在下文中一共展示了SafeProcessHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddProcess

 public void AddProcess(SafeProcessHandle processHandle)
 {
     ValidateDisposed();
     if (!AssignProcessToJobObject(_handle, processHandle))
     {
         throw new InvalidOperationException("Unable to add the process");
     }
 }
开发者ID:mjheitland,项目名称:TableTweaker,代码行数:8,代码来源:ChildProcessManager.cs

示例2: DuplicateHandle

 internal static extern bool DuplicateHandle(
     SafeProcessHandle hSourceProcessHandle,
     SafeHandle hSourceHandle,
     SafeProcessHandle hTargetProcess,
     out SafeWaitHandle targetHandle,
     int dwDesiredAccess,
     bool bInheritHandle,
     int dwOptions
 );
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:Interop.DuplicateHandle_SafeProcessHandle.cs

示例3: DuplicateHandle

		SafeProcessHandle DuplicateHandle(SafeProcessHandle process, IntPtr handle, bool throwOnFail = true)
		{
			SafeProcessHandle dupHandle;
			if (!Win32.DuplicateHandle(process, handle, Win32.GetCurrentProcess(), out dupHandle, 0, false, Win32.DUPLICATE_SAME_ACCESS))
				if (throwOnFail)
					throw new Win32Exception();
				else
					return null;
			return dupHandle;
		}
开发者ID:xyandro,项目名称:NeoEdit,代码行数:10,代码来源:SharedMemoryBinaryData.cs

示例4: GetExitCodeProcess

		public static bool GetExitCodeProcess (SafeProcessHandle processHandle, out int exitCode)
		{
			bool release = false;
			try {
				processHandle.DangerousAddRef (ref release);
				return GetExitCodeProcess (processHandle.DangerousGetHandle (), out exitCode);
			} finally {
				if (release)
					processHandle.DangerousRelease ();
			}
		}
开发者ID:BogdanovKirill,项目名称:mono,代码行数:11,代码来源:NativeMethods.cs

示例5: Protect

		public Protect(SafeProcessHandle handle, VirtualQueryInfo info, int protect)
		{
			this.handle = handle;
			this.info = info;
			this.protect = protect;

			if (protect == info.Protect)
				return;

			int oldProtect;
			if (!Win32.VirtualProtectEx(handle.DangerousGetHandle(), (IntPtr)info.StartAddress, (IntPtr)info.RegionSize, protect, out oldProtect))
				throw new Win32Exception();
		}
开发者ID:xyandro,项目名称:NeoEdit,代码行数:13,代码来源:Protect.cs

示例6: DuplicateHandle

		public static bool DuplicateHandle(HandleRef hSourceProcessHandle, HandleRef hSourceHandle, HandleRef hTargetProcess,
			out SafeProcessHandle targetHandle, int dwDesiredAccess, bool bInheritHandle, int dwOptions)
		{
				MonoIOError error;
				IntPtr nakedTargetHandle;
				bool ret = MonoIO.DuplicateHandle (hSourceProcessHandle.Handle, hSourceHandle.Handle, hTargetProcess.Handle,
					out nakedTargetHandle, dwDesiredAccess, bInheritHandle ? 1 : 0, dwOptions, out error);

				if (error != MonoIOError.ERROR_SUCCESS)
					throw MonoIO.GetException (error);

				targetHandle = new SafeProcessHandle (nakedTargetHandle, true);
				return ret;
		}
开发者ID:BogdanovKirill,项目名称:mono,代码行数:14,代码来源:NativeMethods.cs

示例7: ProcessWaitHandle

        internal ProcessWaitHandle( SafeProcessHandle processHandle): base() {
            SafeWaitHandle waitHandle = null;
            bool succeeded = NativeMethods.DuplicateHandle(
                new HandleRef(this, NativeMethods.GetCurrentProcess()),
                processHandle,
                new HandleRef(this, NativeMethods.GetCurrentProcess()),
                out waitHandle,
                0,
                false,
                NativeMethods.DUPLICATE_SAME_ACCESS);
                    
            if (!succeeded) {                    
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
            }

            this.SafeWaitHandle = waitHandle;         
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:17,代码来源:processwaithandle.cs

示例8: ProcessWaitHandle

        internal ProcessWaitHandle(SafeProcessHandle processHandle)
        {
            // Get the process ID from the process handle.  The handle is just a facade that wraps
            // the process ID, and closing the handle won't affect the process or its ID at all.
            // So we can grab it, and it's not "dangerous".
            int processId = (int)processHandle.DangerousGetHandle();

            // Create a wait state holder for this process ID.  This gives us access to the shared
            // wait state associated with this process.
            _waitStateHolder = new ProcessWaitState.Holder(processId);

            // Get the wait state's event, and use that event's safe wait handle
            // in place of ours.  This will let code register for completion notifications
            // on this ProcessWaitHandle and be notified when the wait state's handle completes.
            ManualResetEvent mre = _waitStateHolder._state.EnsureExitedEvent();
            this.SetSafeWaitHandle(mre.GetSafeWaitHandle());
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:17,代码来源:ProcessWaitHandle.Unix.cs

示例9: ProcessWaitHandle

        internal ProcessWaitHandle(SafeProcessHandle processHandle)
        {
            SafeWaitHandle waitHandle = null;
            SafeProcessHandle currentProcHandle = Interop.mincore.GetCurrentProcess();
            bool succeeded = Interop.mincore.DuplicateHandle(
                currentProcHandle,
                processHandle,
                currentProcHandle,
                out waitHandle,
                0,
                false,
                Interop.DUPLICATE_SAME_ACCESS);

            if (!succeeded)
            {
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
            }

            this.SetSafeWaitHandle(waitHandle);
        }
开发者ID:gitter-badger,项目名称:corefx,代码行数:20,代码来源:ProcessWaitHandle.Windows.cs

示例10: ProcessWaitHandle

        internal ProcessWaitHandle( SafeProcessHandle processHandle): base() {
            SafeWaitHandle waitHandle = null;
            bool succeeded = NativeMethods.DuplicateHandle(
                new HandleRef(this, NativeMethods.GetCurrentProcess()),
                processHandle,
                new HandleRef(this, NativeMethods.GetCurrentProcess()),
                out waitHandle,
                0,
                false,
                NativeMethods.DUPLICATE_SAME_ACCESS);
                    
            if (!succeeded) {                    
#if MONO
                // In Mono, Marshal.GetHRForLastWin32Error is not implemented;
                // and also DuplicateHandle throws its own exception rather
                // than returning false on error, so this code is unreachable.
                throw new SystemException("Unknown error in DuplicateHandle");
#else
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
#endif
            }

            this.SafeWaitHandle = waitHandle;         
        }
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:24,代码来源:processwaithandle.cs

示例11: GetProcessIdFromHandle

 public static int GetProcessIdFromHandle(SafeProcessHandle processHandle) {
     if (IsNt)
         return NtProcessManager.GetProcessIdFromHandle(processHandle);
     else
         throw new PlatformNotSupportedException(SR.GetString(SR.WinNTRequired));
 }
开发者ID:JBlacks,项目名称:referencesource,代码行数:6,代码来源:ProcessManager.cs

示例12: GetProcessPriorityBoost

 internal static extern bool GetProcessPriorityBoost(SafeProcessHandle handle, out bool disabled);
开发者ID:noahfalk,项目名称:corefx,代码行数:1,代码来源:Interop.GetProcessPriorityBoost.cs

示例13: SetPriorityClass

		public static bool SetPriorityClass(SafeProcessHandle handle, int priorityClass)
		{
			bool release = false;
			try {
				handle.DangerousAddRef (ref release);
				return SetPriorityClass (handle.DangerousGetHandle (), priorityClass);
			} finally {
				if (release)
					handle.DangerousRelease ();
			}
		}
开发者ID:BogdanovKirill,项目名称:mono,代码行数:11,代码来源:NativeMethods.cs

示例14: GetProcessTimes

		public static bool GetProcessTimes (SafeProcessHandle handle, out long creation, out long exit, out long kernel, out long user)
		{
			bool release = false;
			try {
				handle.DangerousAddRef (ref release);
				return GetProcessTimes (handle.DangerousGetHandle (), out creation, out exit, out kernel, out user);
			} finally {
				if (release)
					handle.DangerousRelease ();
			}
		}
开发者ID:BogdanovKirill,项目名称:mono,代码行数:11,代码来源:NativeMethods.cs

示例15: SetProcessWorkingSetSize

		public static bool SetProcessWorkingSetSize (SafeProcessHandle handle, IntPtr min, IntPtr max)
		{
			bool release = false;
			try {
				handle.DangerousAddRef (ref release);
				return SetProcessWorkingSetSize (handle.DangerousGetHandle (), min, max);
			} finally {
				if (release)
					handle.DangerousRelease ();
			}
		}
开发者ID:BogdanovKirill,项目名称:mono,代码行数:11,代码来源:NativeMethods.cs


注:本文中的Microsoft.Win32.SafeHandles.SafeProcessHandle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。