Jump to content
  • Advertisement
Sign in to follow this  
tim_shea

WinMain()

This topic is 3553 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

I have been googling up a storm and cannot find any answers, does anyone here know why exactly one is supposed to "return (int)msg.wparam" in a winmain func and not just return 0? I understand that it is returning the code passed in from PostQuitMessage(int) but I can't for the life of me find any difference in testing between returning a 0 or the wparam, especially considering every instance I can find that comes down to a 0 anyways. Any help would be greatly appreciated as I am stumped.

Share this post


Link to post
Share on other sites
Advertisement
Quick answer: because MS says so.

Long answer: When you call PostQuitMessage THAT is where you, the programmer, can decide whether there was an error when shutting down. That is, you might have something like this:
if(shutDownError)
{
PostQuitMessage(1);
}
else
{
PostQuitMessage(0);
}
And this makes it so when you exit WinMain you don't have to keep track of which exit code to use.

Hope that helps.

Share this post


Link to post
Share on other sites
Yes it does help, it is pretty much what I expected but even having gone over that MSDN article a few times already today I was not sure. Thanks for the help.

Share this post


Link to post
Share on other sites
Does it make any difference if a program either returns 1 or 0 or any other value?
Indeed the answer to this question is obvious; so, if a program can return any value, then there must be mechanism that checks this value and processes it. Can you name this 'mechanism'? Can I write a program code that checks the return value of other programs?

Share this post


Link to post
Share on other sites
GetExitCodeProcess() will retrieve the exit code of a process given a handle to the process. Most shells will also be able to allow you to access return value of processes in shell scripts. An example of a program that uses process return values extensively is make, which will stop processing if an error return is given when processing the rules for a given target.

Share this post


Link to post
Share on other sites
Also, from Visual Studio run the program from "Start Debugging" option in the "Debug" menu. When the program exits look in the "Output" window and select "Debug" from the "Show output from" drop-down box to see what the return code was.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!