Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

GetThreadId function

Retrieves the thread identifier of the specified thread.

Syntax


DWORD WINAPI GetThreadId(
  _In_ HANDLE Thread
);

Parameters

Thread [in]

A handle to the thread. The handle must have the THREAD_QUERY_INFORMATION or THREAD_QUERY_LIMITED_INFORMATION access right. For more information about access rights, see Thread Security and Access Rights.

Windows Server 2003:  The handle must have the THREAD_QUERY_INFORMATION access right.

Return value

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

Until a thread terminates, its thread identifier uniquely identifies it on the system.

To compile an application that uses this function, define _WIN32_WINNT as 0x0502 or later. For more information, see Using the Windows Headers.

Requirements

Minimum supported client

Windows Vista [desktop apps | Windows Store apps]

Minimum supported server

Windows Server 2003 [desktop apps | Windows Store apps]

Header

WinBase.h on Windows Server 2003, Windows Vista, Windows 7, Windows Server 2008 and Windows Server 2008 R2 (include Windows.h);
Processthreadsapi.h on Windows 8 and Windows Server 2012

Library

Kernel32.lib

DLL

Kernel32.dll

See also

GetCurrentThreadId
GetProcessId
GetProcessIdOfThread
Process and Thread Functions
Threads

 

 

Show:
© 2017 Microsoft