hStdin and hStdout are always 0. So that's the value the function always will return. I've tested it in Win32 enviroment and returns a number corresponding to the specific handler for each call. 7 and 8 are the usual numbers. I could supose 0 as a valid number in wine, but FlushConsoleInputBuffer(conhanin) fails and tells me I'm using a wrong handler.
those slots are (normally) set when programs starts up, using the SetStdHandle calls (see scheduler/process.c for example)
if you get 0, it (just) means that we have to found out why the initialization process fails in your case (you should get a non zero value)
A+