當前位置: 首頁>>代碼示例>>C#>>正文


C# SafeProcessHandle.DangerousGetHandle方法代碼示例

本文整理匯總了C#中Microsoft.Win32.SafeHandles.SafeProcessHandle.DangerousGetHandle方法的典型用法代碼示例。如果您正苦於以下問題:C# SafeProcessHandle.DangerousGetHandle方法的具體用法?C# SafeProcessHandle.DangerousGetHandle怎麽用?C# SafeProcessHandle.DangerousGetHandle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.Win32.SafeHandles.SafeProcessHandle的用法示例。


在下文中一共展示了SafeProcessHandle.DangerousGetHandle方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: 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

示例2: 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

示例3: ProcessName_internal

		static string ProcessName_internal(SafeProcessHandle handle)
		{
			bool release = false;
			try {
				handle.DangerousAddRef (ref release);
				return ProcessName_internal (handle.DangerousGetHandle ());
			} finally {
				if (release)
					handle.DangerousRelease ();
			}
		}
開發者ID:BrzVlad,項目名稱:mono,代碼行數:11,代碼來源:Process.cs

示例4: GetModules_internal

		ProcessModule[] GetModules_internal (SafeProcessHandle handle)
		{
			bool release = false;
			try {
				handle.DangerousAddRef (ref release);
				return GetModules_internal (handle.DangerousGetHandle ());
			} finally {
				if (release)
					handle.DangerousRelease ();
			}
		}
開發者ID:BrzVlad,項目名稱:mono,代碼行數:11,代碼來源:Process.cs

示例5: TerminateProcess

		public static bool TerminateProcess (SafeProcessHandle processHandle, int exitCode)
		{
			bool release = false;
			try {
				processHandle.DangerousAddRef (ref release);
				return TerminateProcess (processHandle.DangerousGetHandle (), exitCode);
			} finally {
				if (release)
					processHandle.DangerousRelease ();
			}
		}
開發者ID:BogdanovKirill,項目名稱:mono,代碼行數:11,代碼來源:NativeMethods.cs

示例6: 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

示例7: 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

示例8: 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

示例9: WaitForInputIdle

		public static int WaitForInputIdle (SafeProcessHandle handle, int milliseconds)
		{
			bool release = false;
			try {
				handle.DangerousAddRef (ref release);
				return WaitForInputIdle (handle.DangerousGetHandle (), milliseconds);
			} finally {
				if (release)
					handle.DangerousRelease ();
			}
		}
開發者ID:BogdanovKirill,項目名稱:mono,代碼行數:11,代碼來源:NativeMethods.cs

示例10: GetProcessIdFromHandle

 /// <summary>Gets the ID of a process from a handle to the process.</summary>
 /// <param name="processHandle">The handle.</param>
 /// <returns>The process ID.</returns>
 public static int GetProcessIdFromHandle(SafeProcessHandle processHandle)
 {
     return (int)processHandle.DangerousGetHandle(); // not actually dangerous; just wraps a process ID
 }
開發者ID:naamunds,項目名稱:corefx,代碼行數:7,代碼來源:ProcessManager.Unix.cs

示例11: GetLogicalName

		static unsafe string GetLogicalName(SafeProcessHandle handle)
		{
			var data = new byte[2048];
			int size = data.Length;
			var result = NtQueryObject(handle.DangerousGetHandle(), OBJECT_INFORMATION_CLASS.ObjectNameInformation, data, size, ref size);
			if (result < NtStatus.Success)
				throw new Win32Exception();

			string name;
			fixed (byte* dataPtr = data)
				name = ((UNICODE_STRING*)dataPtr)->ToString();

			foreach (var pair in TranslateMap)
				if (name.StartsWith(pair.Key))
					name = pair.Value + name.Substring(pair.Key.Length);

			return name;
		}
開發者ID:xyandro,項目名稱:NeoEdit,代碼行數:18,代碼來源:HandleHelper.cs


注:本文中的Microsoft.Win32.SafeHandles.SafeProcessHandle.DangerousGetHandle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。