Win32 Thread Exit codes

Started by
5 comments, last by Illco 18 years, 11 months ago
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.
...
Advertisement
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.
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
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.
-Mike
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").

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

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.

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

This topic is closed to new replies.

Advertisement