Is it possible to convert an existing visual studio开发者_JAVA技巧 project file that creates a Win32 application into a project file that creates a Win32 "Console" application? If so, how is this done? I've googled and found plenty of people doing the opposite, but none this way.
At the linker level, the distinction is made with the /SUBSYSTEM
switch to the linker. However, since there is so much other stuff built up around the type of project in Visual Studio, sometimes it's easiest to create a new console mode project, and add the existing code to the new project.
I am not aware of an automated way of that. I think you can change all the project settings to make that switch. But it would be tedious. I believe it would be simpler to just create a new project and add the source files to it.
You don't specify your version of visual studio. In the versions with XML project definitions, you can modify the XML. Heck, you might be able to do it with XSLT. In older version, you are better off creating a new project.
You should create two simple projects (one GUI, one Console) and compare the project definition XML files to see what needs to be done.
It is possible, but it depends on how the application was architected. If the design is one that clearly separates business logic from the presentation, you may be able to extract the business logic code and classes into a separate library, if that hasn't yet been done. Once that step is complete, you'll have to create a new API for that library, so that the console application (or any other application) can use it.
On the other hand, if the forms contain business logic, those processes are going to have to be pulled out into new, non-presentation classes and incorporated into your new libraries. As I said...possible, but could be a lot of work.
精彩评论