两种方法:
方法一:
1.工程属性->Linker->System->SubSystem 设置为 Console(/SUBSYSTEM:CONSOLE).
2.将程序中定义的默认入口函数_tWinMain的函数头改为:
int main(int argc, char *argv[])
3._AtlModule对象WinMain函数的参数传SW_SHOWNORMAL。
说明:ATL工程的SubSystem默认设置为Windows,因此没有控制台。将工程属性设置为控制台工程后即可以产生控制台。但是,同时需要修改入口函数的函数头位控制台入口函数的函数头。
方法二:
工程属性->Build Event->Post-Build Event 中添加以下语句:
editbin /SUBSYSTEM:CONSOLE $(TargetPath)
关于editbin:
http://msdn.microsoft.com/en-us/library/xd3shwhf%28VS.80%29.aspx
The Microsoft COFF Binary File Editor (EDITBIN.EXE) modifies Common Object File Format (COFF) binary files. You can use EDITBIN to modify object files, executable files, and dynamic-link libraries (DLL). EDITBIN is not available for use on files produced with the /GL compiler option. Any modifications to binary files produced with /GL will have to be achieved by recompiling and linking.
原理与方法一相同,但是是在可执行程序产生之后通过editbin工具来修改subsystem属性为console。