--
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
http://www.microsoft.com/info/cpyright.htm
Quote:> I'm writing an application that allows to launch a HLDS.exe server, it
works
> fine with telnet server, but the process if launched from telnet has not
his
> 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.
> --
> 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
> http://www.microsoft.com/info/cpyright.htm
> > I'm writing an application that allows to launch a HLDS.exe server, it
> works
> > fine with telnet server, but the process if launched from telnet has not
> his
> > 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.
1. Redirecting stderr: in single process, *not* in a child process.
Hello all.
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
the situation:
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:
<code>
///
/// Function: main()
///
int main ( int argc, char * const argv[] )
{
HANDLE hRead, hWrite;
if ( !CreatePipe( &hRead, &hWrite ,NULL, 10 ) )
return FALSE;
SetStdHandle( STD_ERROR_HANDLE, hWrite );
fprintf( stderr, "This will NOT go to the pipe, but instead to the
console\n" );
return 0;
</code>
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.
Jamie
3. Problem redirecting stdout from child DOS process
4. RRAS stops local ip traffic
5. Creating a Child Process with Redirected Input and Output
6. Console Process w redirected stdout - Buffer does not flush
7. How to redirect STDIO of console process created with CreateProcess() ??
8. Redirecting output of DOS app run in DOS box
9. Registering Active Object in In-Process Server for Out of Process Server, HOW?
10. Redirecting telnet output to serial port
11. Win32 Create Process and DOS Apps