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

Console Magic Needed

0 views
Skip to first unread message

Richard Ulrich

unread,
Oct 29, 1998, 3:00:00 AM10/29/98
to
Hello,

I want to be able to call Windows API functions from within a console
application. To do that, I used the console wizard to create a plain
Windows App, in which I create a console using AllocConsole(). The problem
is that my "printf" statements in thousands of lines of legacy code don't
go anywhere. I need a magic line in the following program.

WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
AllocConsole();
//Magic goes here, and then the following works!?
printf("Hello world");
Sleep(250); //sleep 1/4 second, using a Windoze API function
}

Is this an approach that is too dumb for words? If so, what is a better
way to do it? Should I post this somewhere else?

Thanks,
Richard Ulrich

Chris Uzdavinis (TeamB)

unread,
Oct 29, 1998, 3:00:00 AM10/29/98
to
Richard Ulrich wrote:
> Is this an approach that is too dumb for words?

I wouldn't put it in those terms. <g> But there's a better way...

> If so, what is a better
> way to do it? Should I post this somewhere else?

Make a normal console app, that uses main() and not WinMain(). Then
just include <windows.h> and you're off. Console applications are
still Windows application, so there's nothing special you need to do.

:)
Oh, and I think that this is a good place for the topic. Console app.
stuff probably belongs here, since the heart of your question was
about getting printf() to work.

--
Chris (TeamB)

Richard Ulrich

unread,
Oct 30, 1998, 3:00:00 AM10/30/98
to

Chris Uzdavinis (TeamB) <ch...@uzdavinis.com> wrote in article
<3638FD13...@uzdavinis.com>...


>
> Make a normal console app, that uses main() and not WinMain(). Then
> just include <windows.h> and you're off.

Well, of course! <sheepish grin>

Richard U.

albar...@hotmail.com

unread,
Oct 30, 1998, 3:00:00 AM10/30/98
to
hello

magic is unusual power which you shouldn't play with..

albardooli

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

0 new messages