SetThreadDescription function

Assigns a description to a thread.

Syntax

HRESULT SetThreadDescription(
  HANDLE hThread,
  PCWSTR lpThreadDescription
);

Parameters

hThread

A handle for the thread for which you want to set the description. The handle must have THREAD_SET_LIMITED_INFORMATION access.

lpThreadDescription

A Unicode string that specifies the description of the thread.

Return Value

If the function succeeds, the return value is the HRESULT that denotes a successful operation. If the function fails, the return value is an HRESULT that denotes the error.

Remarks

The description of a thread can be set more than once; the most recently set value is used. You can retrieve the description of a thread by calling GetThreadDescription.

Examples

The following example sets the description for the current thread to "simulation_thread".

C++
HRESULT hr = SetThreadDescription(GetCurrentThread(), L"simulation_thread");
if (FAILED(hr))
{
    // Call failed.
}

Requirements

   
Windows version Windows 10, version 1607 [desktop apps UWP apps] Windows Server 2016 [desktop apps UWP apps]
Target Platform Windows
Header processthreadsapi.h
Library Kernel32.lib
DLL Kernel32.dll

See Also

GetThreadDescription