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
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)
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.
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