Sign in to follow this  

output to console from MFC

This topic is 4014 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 an MDI utility that I've built with MFC (VC8) which I now also want to be able to use from the command line. I have added code to handle command line arguments with the help of CCommandLineInfo. But I can't find anything helpful about how to output text to the same console. I mostly need it to display error messages. I don't want to use a MessageBox when I run the program from the command line. Also how do I exit the program with an error code so that a batch file running the program can catch it?

Share this post


Link to post
Share on other sites
Unfortunately I have already seen that page and it doesn't help. That code opens a new console and outputs to it. I want to output to the console that started the program.

Share this post


Link to post
Share on other sites
Quote:
Original post by Decept
Unfortunately I have already seen that page and it doesn't help. That code opens a new console and outputs to it. I want to output to the console that started the program.
printf() or cout should do the trick.

As for exiting with an error code, I seem to recall there's a file (MyApp.cpp or something) which has a WinMain-like function in it. You should modify that to return an error code instead of 0.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
MFC overrides console output...
I had found this article while I was using VC++6, but it may still work with VC++2005: http://www.codeproject.com/cpp/EditBin.asp

all you have to do is:
EditBin MyProgram.exe /SUBSYSTEM:CONSOLE

Share this post


Link to post
Share on other sites

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