Monday, March 19, 2012

vs2010 Add console to win32

source: http://stackoverflow.com/questions/3009042/how-to-view-printf-output-in-win32-app-on-visual-studio-2010

I'd done this before with utilities and what not but this is by far the simplest solution I've seen to getting console output into a win32 vs project. I really like it so far.

Go to properties (alt + f7).

Linker > System > SubSystem.

Change it to Console.

Go your your main file.

Go to :



int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR    lpCmdLine,
int       nCmdShow){...}




Below that function add:



int main() {
return _tWinMain(GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW);
}



And your done.

No comments:

Post a Comment