Boost logo

Boost Users :

Subject: Re: [Boost-users] [thread] Obtaining thread id on Windows
From: Bill Buklis (boostuser_at_[hidden])
Date: 2009-09-09 18:56:53


> -----Original Message-----
> From: John Wilkinson [mailto:jwilkinson_at_[hidden]]
> Sent: Wednesday, September 09, 2009 2:50 PM
> To: boost-users_at_[hidden]
> 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 --


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net