If you can set your service to SERVICE_INTERACTIVE_PROCES
Main Topics
Browse All TopicsI have a windows service written in C++. I want to view its stdout, as there is output to stdout using printf. Is there an easy way to do this? I can write more debug code, but i am trying to avoid that wasted time. Im using this service across W2K, XP, and W2K3. My specific issue i need to see the ouput for is on W2K.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
If you can set your service to SERVICE_INTERACTIVE_PROCES
jkr - I like the first solution, what i am doing is makeing the debug version of the code use desktop interactive, and the release stays the same. Now, as i am working on this, maybe you can help explain a bit - after AllocConsole, what is all that other stuff? It appears that the critical line is setvbuf? Once i call all this it should work? Im working on it now, so i may get it before you respond, but i'd like to better understand the lasn couple lines.
ok, well the allocConsole seems to be working (the _O_TEXT didn't compile for some reason, i guess im missing a header, but intellisense scoped it out for me so i just used the actual value)
Regarding the second approach, i was a little unsure where the text goes... i currently use OutputDebugString in parts of my code, but the only place i know to view it is in the VS IDE. I would be interested in using this if you could use it with windbg, or some other method of seeing the ouput.
>>Regarding the second approach, i was a little unsure where the text goes...
The text goes to an internal trace buffer of Windows. Actually, when you debug an application, you may see test in the debugger's "Output Window", that's the same mechanism DebugView helps you see that without a debugger. That's a very convenient method IMO, we're using that a lot.
>>can you set the default buffer size of the console window after AllocConsole?
You can do that using 'SetConsoleScreenBufferSiz
jkr, you are the expert! When discussing debugging things with me at least, you need to make no assumptions. I am very unfamiliar with the available tools and mechanisms. What is DebugView?
I was able to figure out that the problem is not what i originally thought it was, so this OutputDebugString may be the only way, because now i cannot modify the output or it will affect the application.
'DebugView' (http://technet.microsoft.
ok, that wasn't the problem but i figured out i need to now debug a process once it gets launched, so the process hasn't been created.. is there a way to do that? If not, how do i code a break point into the code so i can attach a debugger? My first thought is to make a loop that wont end until i change the value of a variable from the debugger, but i dont even know how to do that in windbg. I can start a new question if you think that would be better.
Coding a breakpoint is quite simple, just add
DebugBreak();
or
__asm { int 3};
But, from Visual Studio, you ca nalways use "Debug|Attach to Process..." or right click in the Task Manager to debug any process of your choice. BTW, see also http://support.microsoft.c
Business Accounts
Answer for Membership
by: evilrixPosted on 2008-02-19 at 07:42:19ID: 20929392
>> I want to view its stdout, as there is output to stdout using printf
It'd probably be simplest just to write a log file.