Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Modifying an AppWiz application to be console application

Posted on 1998-02-13
1
Medium Priority
?
235 Views
Last Modified: 2013-11-20
Is it possible to modify a standard program generated
by the AppWizard so it can be started As a console application?

It also has to be able to accept input :  
 main(int argc, char **argv)

and the AppWizard program can't be a spawned
process of the console app.

Thanks,

Eric
0
Comment
Question by:nielsew
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
mikeblas earned 80 total points
ID: 1316172
It is possible, but it's not worth the trouble--you end up removing ten times more than you would use.

I don't understand your requirement that "the AppWizard program can't be a spawned process of the console app". I can't reconcile your statement: a console application is free to create windows, so that can't be what you mean.  And a console app can spawn a /SUBSYSTEM:WINDOWS application any time it wants to.  So, that can't be what you mean.

What is it that you're really trying to say?

You don't mention which version of which development environment you're using, so I'll assume you're using VC++ 5.0. Anyhow, to get an MFC app that runs as a console, you should:

1) Ask for a new "Win32 Console Application"
2) In the resulting project, use the "Settings" command in the "project menu"
3) Make sure "All Configurations" is selected in the "Settings For" box
4) In the "Microsoft Foundation Classes" drop down, select either "in a Shared DLL" or "in a static library"--whichever you like.
5) Press OK to close the "Project Settings" dialog
6) Create a new *.CPP file.  Name it whatever you like.
7) Add the *.CPP file you created to your project.
8) Edit the *.CPP file.  Put this code in it:

#include <afx.h>
#include <afxwin.h>

CWinApp theApp;

int main(int argc, char* argv[])
{
   int nRetVal = 1;

   if (!AfxWinInit(GetModuleHandle(), NULL, GetCommandLine(), 0))
   {
      // MFC failed to initialize.
      printf("startup error!");
   }
   else
   {
      // your app is up!  make whatever Win32 API, standard lib,
      // or MFC calls you'd like.

      CString str("Hello");
      printf("%s world!\n", (LPCTSTR) str);
      nRetVal = 0;
   }

   return nRetVal;
}

9) Save it.
10) Build it.

You're in business.

.B ekiM



0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question