SetThreadContext

  BOOL SetThreadContext(hThread, lpContext)    
  HANDLE hThread;    
  LPCONTEXT lpContext;    

The SetThreadContext function sets the context in the specified thread. The function allows selective context to be set based on the value of the ContextFlags member of the context structure. The specified thread does not have to be being debugged in order for this function to operate. The caller must simply have a handle to the thread that was created with THREAD_SET_CONTEXT access.

Parameters

hThread

Supplies an open handle to a thread whose context is to be written. The handle must have been created with THREAD_SET_CONTEXT access to the thread.

lpContext

Supplies the address of a context structure that contains the context that is to be set in the specified thread. The value of the ContextFlags field of this structure specifies which portions of a threads context are to be set. Some values in the context structure are not settable and are silently set to the correct value. This includes cpu status register bits that specify the privileged processor mode, debug register global enabling bits, and other state that must be completely controlled by the operating system.

Return Value

The return value is true if the context was set; otherwise it is FALSE if an error occurred.

See Also

GetThreadContext