-
Show printf's from dll
If i have printf("something"); in my DLL how do i make it appear to the screen?
Ideally I would like the execution screen to appear, i would watch the printf's, then dissappear once th execution is finished.
as of now i never see the execution screen
im using MSVC6
thanks for your help... this board is amazing.
-
The printf function cannot be the dll. It should be in the stdio.h.
Did you mean a different function such as user defined function which is named other than printf in the dll, which need to access in your main?
ssharish2005
-
nonono
i have a function that does a bunch of stuff but print to the screen during the execution of my dll.
I want to see those prints to screen.
right now i cant see my dll executing at all.
-
Most likely cause your dll doesn't have a console associated with it. Just because you are calling your dll from your code doesn't mean it has your console with it.
-
Set the DLL's stdout and stdin handles (ie inherit them when you init the dll), to whatever and read it via a pipe. See MSDN
-
My guess is that you are using a DLL as part of a windows applicaiton, so there's no console attached to the application - is this correct? If so, you've got two choices:
- replace printf's with fprintf's (and open a log-file at DLL init, close at DLL exit)
- use AllocConsole() to create a console window (this does all the magic necessary to get printf working)
For many things, the first approach is probably better than the second, as you get a permanent result. But if you want to see the progress for example, then the console window is a workable solution (but using a windows style progress is probably better).
--
Mats
-
hmmm.. the AllocConsole() is exactly what i want but it doesnt seem to work
it brings up a console but it doesnt seem to write to it.
my program is like this:
Code:
AllocConsole();
Printf("blh blh");
FreeConsole();
OUTPUT:
________________
| |
| |
|_______________|
there is nothing in the console just a black screen.
do I have to do some getConsolewindow() stuff?
-
-