-----Original Message----- From: John Wilkinson [mailto:jwilkinson@tsystem.com] Sent: Wednesday, September 09, 2009 2:50 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [thread] Obtaining thread id on Windows
If you cannot store the thread ID when the thread is created, the best way (in my experience) to get the thread ID is to have the thread itself store it in a predetermined location when the thread starts up (using Ray's suggestion of GetCurrentThreadId()).
If you have a window associated with the thread, then you can use the easier function GetWindowThreadProcessId. Otherwise you can use NtQueryInformationThread, although it may be simpler to store the thread ID on creation. See http://www.codeguru.com/forum/showthread.php?t=355572 for an example using NtQueryInformationThread. It's a good guess that GetThreadId is a wrapper for NtQueryInformationThread. -- Bill --