Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MFC console application

43 views
Skip to first unread message

HASAN

unread,
Nov 13, 2008, 2:48:19 PM11/13/08
to
Hi
can any one tell me how can I get MFC functionality in my console
applications? I want to have CAsynchSocket on my console apps. it seems
there is no support for using new projects wizard in this way.
thanks in advance

Hasan

BobF

unread,
Nov 13, 2008, 3:08:28 PM11/13/08
to

VS2005:

Use the Win32 Console App wizard. Click Application Settings and Check
the Add common header files for MFC checkbox

Ajay Kalra

unread,
Nov 13, 2008, 3:17:59 PM11/13/08
to

You can use MFC in a console app as well. That option is provided when
you start the wizard for a console. Make sure you select it. Once you
have that, you can use CAsyncSocket in your project as well.

--
Ajay

Joseph M. Newcomer

unread,
Nov 13, 2008, 5:13:57 PM11/13/08
to
Just specify when you create it that you want MFC support.

Of course, you *are* using the wizards to create the app, right?
joe

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Malachy Moses

unread,
Nov 13, 2008, 5:22:26 PM11/13/08
to

You should not use CAsyncSocket in a console application.
CAsyncSocket relies on the existence of a message pump, in order to
deliver asynchronous notifications to your application (the
notifications start out as ordinary Windows messages). A console app
does not have a message pump, so it will not be able to receive
asynchronous notifications.

HASAN

unread,
Nov 13, 2008, 6:42:29 PM11/13/08
to
does it mean I have to use the Winsock API directly without using MFC
classes?

"Malachy Moses" <malach...@gmail.com> wrote in message
news:ffa3b4a3-2f52-43f0...@r37g2000prr.googlegroups.com...

Joseph M. Newcomer

unread,
Nov 14, 2008, 12:15:18 AM11/14/08
to
Actually, you can create a secondary thread with a message pump to handle the sockets.
joe

Joseph M. Newcomer

unread,
Nov 14, 2008, 12:23:47 AM11/14/08
to
Or you could buy a third-party asynchronous socket library (which is what I often
recommend). Dundas, SocketTools, StingRay, and a few others exist, and there are probably
free versions. Using the raw API for asynchronous sockets is an exercise in pain
endurance.

Of course, there is a serious question about why you need a console app for this purpose.
What value does a console app add that a GUI app wouldn't fulfill? The last time I had to
do one of these, I built a dialog-based app that sits in the tray.
joe

0 new messages