How to get the name of a Win32 Thread?

Michael Kelley picture Michael Kelley · Feb 20, 2012 · Viewed 10.2k times · Source

I know of the non-intuitive process to set the name of a thread under Windows (see "How to set name to a Win32 Thread?"). Is there a way to get the name of the thread? I don't see any Windows API that lets me do this (http://msdn.microsoft.com/en-us/library/windows/desktop/ms684847(v=vs.85).aspx).

Answer

Ana Betts picture Ana Betts · Feb 20, 2012

Threads don't actually have names in Win32. The process via RaiseException is just a "Secret Handshake" with the VS Debugger, who actually stores the TID => Name mapping. Windows itself has no notion of a thread "Name".