@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: The OpenThread API !!!!C# Signature: [DllImport("kernel32.dll", SetLastError = true)] static extern Microsoft.Win32.SafeHandles.SafeAccessTokenHandle OpenThread( ThreadAccess dwDesiredAccess, bool bInheritHandle, uint dwThreadId ); [DllImport("kernel32.dll", SetLastError = true)] static extern IntPtr OpenThread(ThreadAccess dwDesiredAccess, bool bInheritHandle, uint dwThreadId); !!!!User-Defined Types: [Flags] public enum ThreadAccess : int { TERMINATE = (0x0001) , SUSPEND_RESUME = (0x0002) , GET_CONTEXT = (0x0008) , SET_CONTEXT = (0x0010) , SET_INFORMATION = (0x0020) , QUERY_INFORMATION = (0x0040) , SET_THREAD_TOKEN = (0x0080) , IMPERSONATE = (0x0100) , DIRECT_IMPERSONATION = (0x0200) } !!!!Notes: None. !!!!Tips & Tricks: Use the SafeAccessTokenHandle version where possible, as it will ensure proper disposal of the handle. If you use the IntPtr version, use a try/finally block to ensure you call Kernel32.[CloseHandle] !!!!Sample Code: private static void SuspendProcess(int pid) { var process = Process.GetProcessById(pid); if (process.ProcessName == string.Empty) { return; } foreach (ProcessThread thread in process.Threads) { using (var handle = OpenThread( ThreadAccess.SUSPEND_RESUME, false, (uint)thread.IdThreadAccess) ) // using block ensures finalizer closes handle { if (!handle.IsInvalid) { SuspendThread(pOpenThread); } } } } !!!!Alternative Managed API: Do you know one? Please contribute it! Documentation: OpenThread@msdn on MSDN
Edit kernel32.OpenThread
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.