Sign in to follow this  

Win32 Thread Exit codes

This topic is 4593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, Does anyone know where I can find a reference to all the Win32 Thread exit codes? Visual Studio displays them after you finish debugging, but unfortunately the error codes themselves are fairly cryptic. I'm pretty sure anything other than '0' is bad, but what do the others mean? Thanks in advance.

Share this post


Link to post
Share on other sites
I couldn't find a table or anything, but one thing you may want to look into is using the GetLastError function in order to get the last error and display it. You will have to work with that function some for it is meant to exit a process, but if you use those concepts, you should be able to get the error information. One idea, not sure if it'll work.

Share this post


Link to post
Share on other sites
With visual studio a handy tool ships: 'errlook.exe'. It allows you to type in a program exit code and gives you the description of the error. I'm not sure if it works for thread exit codes but they might be just the same. If you have visual studio look in
Microsoft Visual Studio\Common\Tools

See if you can find it or, otherwise, I might send it to you. There also may be similar tools available online.

Greetz,

Illco

Share this post


Link to post
Share on other sites
Thread exit codes and error codes are completely different things... For error codes you can use some tool like suggested above or you can just look in winerror.h (for most things).

The exit code returned by a thread is up to the app. It could mean anything.

Share this post


Link to post
Share on other sites
Handy tip for MSVC (unrelated to thread return values):

1) place a breakpoint on the line immediately after any Win32 function that returns errors via GetLastError() and run your app in the debugger.

2) In the Watch window of the debugger, enter a new watch name: @err,hr

3) voila! - the "@err" part calls GetLastError() and the ",hr" part translates the error code to a message string.

The ",hr" thing can be used to translate specific error codes or variables too (e.g. "201,hr" or "nResult,hr").

Share this post


Link to post
Share on other sites
Quote:
Does anyone know where I can find a reference to all the Win32 Thread exit codes?


You set them yourself when your thread terminates using either ExitThread(X) or _endthreadex(X) (depending on how you started the thread); you can then retrieve the value using "GetExitCodeThead()" after the thread has completed. The values are otherwise meaningless...

Jans.

Share this post


Link to post
Share on other sites
Pity they do not run exactly in parallel to program exit code. However the following:
Quote:

The exit code returned by a thread is up to the app. It could mean anything.

Quote:

You set them yourself when your thread terminates [...]. The values are otherwise meaningless...

is some sloppy argumentation. A program can also return anything it likes as specified by the programmer -- but that does not mean there is no actual meaning in the usual interpretation. Unfortunately, there is no such default interpretation for thread exit codes besides
- zero signifies success
- non-zero signifies a problem
- If a thread happens to return STILL_ACTIVE (259) as an error code, applications that test for this value could end up in an infinite loop. (MSDN)

Greetz

Illco

Share this post


Link to post
Share on other sites

This topic is 4593 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this