Hi all,
I tried using GetCurrentThread to get the Handle of the current thread
but it keeps returning 0xfffffffe for all the threads that I access it
in. This is not the correct handle. Am I missing any prerequisite
calls or something else?
Regards,
..ab
David Lowndes - 07 Jun 2007 18:50 GMT
>I tried using GetCurrentThread to get the Handle of the current thread
>but it keeps returning 0xfffffffe for all the threads that I access it
>in. This is not the correct handle. Am I missing any prerequisite
>calls or something else?
GetCurrentThread returns a pseudo handle - "a special constant that is
interpreted as the current thread handle".
What's your problem with it?
Dave
Carl Daniel [VC++ MVP] - 07 Jun 2007 18:54 GMT
> Hi all,
> I tried using GetCurrentThread to get the Handle of the current thread
> but it keeps returning 0xfffffffe for all the threads that I access it
> in. This is not the correct handle. Am I missing any prerequisite
> calls or something else?
Adding to David's reply, you can get a real handle for the current thread by
using DuplicateHandle, passing GetCurrentThread() as the source handle
value. You are then responsible for (eventually) closing the handle
returned by DuplicateHandle.
If you created the current thread yourself, the handle is returned by
CreateThread or _beginthreadex. If you didn't create the thread, then
GetCurrentThread/DuplicateHandle is the way to go.
-cd
Doug Harrison [MVP] - 07 Jun 2007 19:39 GMT
>Hi all,
>I tried using GetCurrentThread to get the Handle of the current thread
>but it keeps returning 0xfffffffe for all the threads that I access it
>in. This is not the correct handle. Am I missing any prerequisite
>calls or something else?
The documentation explains everything:
GetCurrentThread
http://msdn2.microsoft.com/en-us/library/ms683182.aspx

Signature
Doug Harrison
Visual C++ MVP
otengo@gmail.com - 10 Jun 2007 13:26 GMT
On Jun 7, 9:54 pm, ote...@gmail.com wrote:
> Hi all,
> I tried using GetCurrentThread to get the Handle of the current thread
[quoted text clipped - 5 lines]
>
> ..ab
(oops, whenever i post from the google groups i always forget to come
back looking for a reply ... too bad my outlook express is not working
due to some firewall issues.)
Thanks for the reply guys. I understand now finally what u guys have
told me. I actually wanted the handles cuz I wanted to pass them in
the waitformultipleobjects function. MSDN sometimes talks in a way
that my kind of less-knowledged people dont seem to get it and all
thats needed is a little bit extra info in easy to understand english
sentences (where you guys come in) :).
Thanks all.
..ab