SetThreadDescription function (processthreadsapi.h)

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.

SetThreadDescription is only available by Run Time Dynamic Linking on Windows Server 2016, 1607.

Examples

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

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

Requirements

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

See also

GetThreadDescription, How to: Set a Thread Name in Native Code