473,806 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GetCurrentThrea d not returning correct handle

Hi all,
I tried using GetCurrentThrea d 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 9031
>I tried using GetCurrentThrea d 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?
GetCurrentThrea d 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.c omwrote in message
news:11******** **************@ g4g2000hsf.goog legroups.com...
Hi all,
I tried using GetCurrentThrea d 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 GetCurrentThrea d() 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
GetCurrentThrea d/DuplicateHandle is the way to go.

-cd
Jun 7 '07 #3
On Thu, 07 Jun 2007 09:54:24 -0700, ot****@gmail.co m wrote:
>Hi all,
I tried using GetCurrentThrea d 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:

GetCurrentThrea d
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.co m wrote:
Hi all,
I tried using GetCurrentThrea d 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 waitformultiple objects 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
3909
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, time and timezone, get the results returned by date() are 11 hours behind. Any ideas what is going wrong?
4
3391
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 want to search on more than one value my function in the QBE correctly returns "1 Or 4" (for example), but something's getting garbled and I'm not getting the same data back if I just enter "1 Or 4" (w/o quotes) in the QBE grid. My guess is that...
4
2840
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 bc; string s; bc = Request.Browser; ....
0
864
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 Microsoft.Web.UI.WebControls.TreeViewClickEventArgs) Handles TreeView1.Expand
4
1266
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 CurrentRowIndex property gives me the selected row of the data grid which no longer matches the data table when the columns have been resorted. Thanks!!!
3
4679
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 alert("Year:" + d.getYear()); -> 2006 alert("Month:" + d.getMonth()); -> 3
5
2590
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 tell me where im going wrong and correct me. U can run it and check! Thanks Prads #include <iostream> #include <fstream> #include <cstring> #include <cmath>
12
1857
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 their last name in lowercase, validate it, and return it. Then return the full name and show how many characters it consist of. My validation works fine but it's not returning the name. ie...Please enter your first name in lowercase: mike ...
7
1753
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 object and if it meets certain requirements then the object's id is returned. something like select o.id from objects o, events e, objecteventmap oem, (select max(date), o.id from events e, objects o, objecteventmap oem where e.id = oem.eventid...
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10620
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10372
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.