GetCurrentThread not returning correct handle

  • Thread starter Thread starter otengo
  • Start date Start date
O

otengo

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
 
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
 
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
 
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

(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
 
Back
Top