Difference between Console and Win32?

Could someone explain to me why programs in C++ that will compile in a Win32 Console, wont in a Win32, and vice versa.

I add #include "stdAfx.h" to the programs when I try running it in a Win32 project but still doesn't work.

If there's already a post that will answer my quetion somewhere already could someone point me too it, I'm new to this site.

I'm using MS Visual C++ 2010 Express, if it makes any difference.

Thanks
closed account (DSLq5Di1)
http://stackoverflow.com/questions/574911/difference-between-windows-and-console-application
Hmm that sort of explained somethings. So what determines which you should use, what sort of projects are better in one or the other? Can you do exactly the same things with a windows app as you can with a console if you do a bit more coding?
Can you do exactly the same things with a windows app as you can with a console if you do a bit more coding?


Not quite!

If you want your program to run from the command line and write its output to the current console, you need to link to the console subsystem. Then, when you run the app, Windows will attach it to the current console.

A Windows application can allocate a new console and write to it, but it is not attached to nor can it get hold of [1] the current console. So a Windows (as in, linked to the Windows subsystem) app which is run at the command line cannot write to the console that launched it.

The other difference is that console apps must implement a main() entry point, whereas Windows apps must implement a WinMain entry point [2].

Andy

[1] There might be an evil way of achieving this, but there is no safe, official way!
[2] Some cross-platform GUI toolkits require you to provide a main(). The toolkit provides Windows with the required WinMain and then calls your main(). I assume this is for consistency with Linux?
Last edited on
Topic archived. No new replies allowed.