Skip to main content
SetThreadDescription function

Assigns a description to a thread.

Syntax


HRESULT WINAPI SetThreadDescription(
  _In_ HANDLE hThread,
  _In_ PCWSTR lpThreadDescription
);

Parameters

hThread [in]

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

lpThreadDescription [in]

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".


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]

Header

ProcessThreadsApi.h

Library

Kernel32.lib

DLL

Kernel32.dll

See also

GetThreadDescription