473,396 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

GetCurrentThread not returning correct handle

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

Jun 7 '07 #1
4 8973
>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
Jun 7 '07 #2
<ot****@gmail.comwrote in message
news:11**********************@g4g2000hsf.googlegro ups.com...
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
Jun 7 '07 #3
On Thu, 07 Jun 2007 09:54:24 -0700, ot****@gmail.com wrote:
>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

--
Doug Harrison
Visual C++ MVP
Jun 7 '07 #4
On Jun 7, 9:54 pm, ote...@gmail.com wrote:
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

Jun 10 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Funnyweb | last post by:
I have just notices that the date() function is not returning the correct date/time on my "server". I am running apache2 on my winxp pro laptop. My system clock is set to the correct date,...
4
by: i. dzhugashvili | last post by:
I'm hoping someone can help me here. I'm having problems using a function to get the search criteria for a column in the QBE grid. The column's data type is Long and the problem is that if I...
4
by: Earl T | last post by:
When I try to get the netscape version for version 7, I get the HttpBrowserCapabilities class returning the version as 5 and not 7. (see code and output below) CODE HttpBrowserCapabilities...
0
by: agarrettb | last post by:
Hi all, having problem with a TreeView. I click node 2.1 in my tree, but the node object returned is 2. Here is a little code: Private Sub TreeView1_Expand(ByVal sender As Object, ByVal e As...
4
by: Brian Mitchell | last post by:
I'm sure this is a very dumb question but when a user clicks on a row in my data table (which has been sorted) how do I return the correct row index for my underlying data table? The...
3
by: maflatoun | last post by:
Hi, I must be losing my mind why is the following code returning wrong values? var d = new Date(); alert(d); -> Fri Apr 7 09:28:18 EDT 2006 alert("Hour:" + d.getHours()); -> 9...
5
by: prads | last post by:
Hello, the following code doesnot return the corect values to the main function. However it prints the correct values within the function. Also the same when written in C works absolutely fine. Pls...
12
by: abernut | last post by:
Hello, I am very new to the C++ world (2 months) I have an assignment where we need to write a program that asks the user for his first name in lowercase, validate it, and return it. Then ask for...
7
by: BiffMaGriff | last post by:
I have an query I run against an Oracle Connection. I have these objects, an event table and a table to map my objects to my events. My select statement selects the most recent event for each...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.