Platform SDK: DLLs, Processes, and Threads |
The OpenThread function opens an existing thread object.
HANDLE OpenThread( DWORD dwDesiredAccess, // access right BOOL bInheritHandle, // handle inheritance option DWORD dwThreadId // thread identifier );
Value | Description |
---|---|
SYNCHRONIZE | Enables the use of the thread handle in any of the wait functions. |
THREAD_ALL_ACCESS | Specifies all possible access flags for the thread object. |
THREAD_GET_CONTEXT | Enables the use of the thread handle in the GetThreadContext function. |
THREAD_QUERY_INFORMATION | Enables the use of the thread handle to read certain information from the thread object, such as the exit code (see GetExitCodeThread). |
THREAD_SET_CONTEXT | Enables the use of the thread handle in the SetThreadContext function. |
THREAD_SET_INFORMATION | Enables the use of the thread handle to set certain information for the thread object. |
THREAD_SET_THREAD_TOKEN | Enables the use of the thread handle in the SetTokenInformation function to set the thread token. |
THREAD_SUSPEND_RESUME | Enables the use of the thread handle in the SuspendThread or ResumeThread function to suspend and resume the thread. |
THREAD_TERMINATE | Enables the use of the thread handle in the TerminateThread function to terminate the thread. |
If the function succeeds, the return value is an open handle to the specified process.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
The handle returned by OpenThread can be used in any function that requires a handle to a thread, such as the wait functions, provided you requested the appropriate access rights. The handle is granted access to the thread object only to the extent it was specified in the dwDesiredAccess parameter.
When you are finished with the handle, be sure to close it by using the CloseHandle function.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Unsupported.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Processes and Threads Overview, Process and Thread Functions, CloseHandle, GetExitCodeThread, GetThreadContext, ResumeThread, SetThreadContext, SetTokenInformation, SuspendThread, TerminateThread