Convert a console project into a Win32 GUI project or the other way around.
2011-06-24 22:50
302 查看
Jeffrey Richter mentioned in his classical Programming application for Windows, 4th edition that if a developer made a mistake by creating a Win32 project when what he really meant was a Console project, he has at least the following 2 options to fix it. (Jeffery Richter mentioned 4 options actually. But the first 2 are not interesting at all.)
Click on the Link tab of the Project Settings dialog box and change the /SUBSYSTEM:WINDOWS switch to /SUBSYSTEM :CONSOLE. This is an easy way to fix the problem; few people are aware that this is all they have to do.
Click on the Link tab of the Project Settings dialog box and delete the /SUBSYSTEM:WINDOWS switch entirely. This is my favorite choice because it gives you the most flexibility. Now, the linker will simply do the right thing based on which function you implement in your source code. I have no idea why this isn't the default when you create a new Win32 Application or Win32 Console Application project with Visual C++'s Developer Studio.
Reader may come to the conclusion that the project type, or consequently the application type, is determined by the entry point function name you choose. If you use main(), you'll get a console project and get an console application in the end, if you choose WinMain(), you'll get a Win32 project and a Win32 application in the end.
Not necessarily. The above statement is only true when the /ENTRY option is not used for the linker. With this option, you can specify any function name as the Entry Point Function of your application. If you do so, whether your application will be a console application or a Win32 application will be solely determined by the /SUBSYSTEM option.
This means, it's completely OK to have a GUI application that starts with a main() function. It's also completely OK to have a console application that starts with a WinMain() function. Name doesn't matter!
Click on the Link tab of the Project Settings dialog box and change the /SUBSYSTEM:WINDOWS switch to /SUBSYSTEM :CONSOLE. This is an easy way to fix the problem; few people are aware that this is all they have to do.
Click on the Link tab of the Project Settings dialog box and delete the /SUBSYSTEM:WINDOWS switch entirely. This is my favorite choice because it gives you the most flexibility. Now, the linker will simply do the right thing based on which function you implement in your source code. I have no idea why this isn't the default when you create a new Win32 Application or Win32 Console Application project with Visual C++'s Developer Studio.
Reader may come to the conclusion that the project type, or consequently the application type, is determined by the entry point function name you choose. If you use main(), you'll get a console project and get an console application in the end, if you choose WinMain(), you'll get a Win32 project and a Win32 application in the end.
Not necessarily. The above statement is only true when the /ENTRY option is not used for the linker. With this option, you can specify any function name as the Entry Point Function of your application. If you do so, whether your application will be a console application or a Win32 application will be solely determined by the /SUBSYSTEM option.
This means, it's completely OK to have a GUI application that starts with a main() function. It's also completely OK to have a console application that starts with a WinMain() function. Name doesn't matter!
相关文章推荐
- Compression then encryption or the other way around?(转载)
- Unity3d 打包时报错 CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
- Unity3d 打包时报错 CommandInvokationFailure: Unable to convert classes into dex format. See the Console f
- Convert an object into Json using SBJson or other JSON library
- Unable to convert classes into dex format. See the Console for details
- Buying your way into the App Store’s Top 25
- Inside Windows:An In-Depth Look into the Win32 Portable Executable File Format
- An In-Depth Look into the Win32 Portable Executable File Format, Part 2
- 关于Android SDK工具Lint的误报:Class referenced in the manifest, com.xxx.xxx.receiver.NetworkReceiver, was not found in the project or the libraries
- An In-Depth Look into the Win32 Portable Executable File Format
- Splitting an existing replicat ( or extract ) with the RANGE command into multiple replicats (extrac
- the way to compart a long code line into parts in order to make the Horizontal scroll bar disappear in V.S' Text Editor
- Resolve the issue that can not convert the silverlight project from the low version to high version
- 错误: Some part of your SQL statement is nested too deeply. Rewrite the query or break it up into smaller queries.
- String Convert for Windows // other way
- Some insight into the read cache of ZFS - or: The ARC
- GUI 0.6计划!-----The Flash will into QuartzGUI!
- The best way to convert and burn videos to dvd
- 问题-XE8报Object factory for class{xx-xx-xx-xx-xx} is missing. To register it, you can drop component[TFDGUIxWaitCursor] into your project.
- Visual C the best way to get the contents of a file directory into a list