This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
Quote:> I'm writing an application that allows to launch a HLDS.exe server, it
> fine with telnet server, but the process if launched from telnet has not
> console in desktop.
> If my program is launched manually, then it spawn correctly hlds console
> Should i use createProcessAsUser?
> Tell me how please
> Best Regards
> Marco Montesissa.
> This posting is provided "As Is" with no warranties, and confers no
> Use of included script samples are subject to the terms specified at
> > I'm writing an application that allows to launch a HLDS.exe server, it
> > fine with telnet server, but the process if launched from telnet has not
> > console in desktop.
> > If my program is launched manually, then it spawn correctly hlds console
> > windows.
> > Should i use createProcessAsUser?
> > Tell me how please
> > Best Regards
> > Marco Montesissa.
I spent a long day yesterday battling trying to achieve something that
sounds very simple until you actually try and do it. Let me explain
I've taken a third party bit of server software that comes with a BSD
license and I have written a thin wrapper for it using our standard C+
+ classes for logging, configuration, service management etc. The
source code for the original software is basically unchanged, and I
want to keep it this way so that is simple to upgrade it when need be.
The problem is that the software uses simple c-style logging to
stderr, using fprintf mostly. What I want to do is capture this
output and send it somewhere else within my own application.
On unix I have solved this problem in the following manner:
? Create a pair of interconnected sockets using the "socketpair" call.
? Use dup2 to make stderr send its output to one of these sockets.
? Start a thread to monitor the other end of the socket and process
the output as it arrives.
This would all work fine on windows except on win32, sockets are not
the same as file descriptors. In short the method I am using on Unix
will not work on windows, or not that I can see.
I've spent hours trying to find an alternative solution to this simple
problem, playing with SetStdHandler, pipes, named pipes, sockets and
all sorts. I have yet to find a way to redirect everything sent to
"stderr" to a place of my choosing.
An example of how hard this is can be seen in the following code:
/// Function: main()
int main ( int argc, char * const argv )
HANDLE hRead, hWrite;
if ( !CreatePipe( &hRead, &hWrite ,NULL, 10 ) )
SetStdHandle( STD_ERROR_HANDLE, hWrite );
fprintf( stderr, "This will NOT go to the pipe, but instead to the
Even though I redirect the stderr to my pipe, that output will go to
the screen. Apparantly stderr has already been setup within the
printf code, and calling SetStdHandle has no effect.
In short I'm completely stumped. If someone can show me a way to do
this I would be most grateful. All examples on the web seem to be
oriented towards how to redirect the output of a child process, which
is really not what I'm trying to do here.
Thanks in advance.