473,395 Members | 1,443 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Repost: NT Service and redirection of stdOut/stdError

I have made a NT Service in c# and I need to use some features provided in a
legacy C library (it can be interfaced with callbacks and normal calls). So
far, no problem, I used p/Invoke and all is fine. However, this library
writes to stdOut/stdError. :-((
Is there a way at service startup (or later) to redirect stdOut/stdError to
files so as to prevent my Service to crash?

Thanks!

José

Nov 15 '05 #1
1 1720
Found it:

Must use:

[ DllImport( "Kernel32.dll" )]

internal static extern bool SetStdHandle( int nStdHandle, HandleRef hndRef);

José

"José Joye" <jo*******@KILLTHESPAMSbluewin.ch> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I have made a NT Service in c# and I need to use some features provided in a legacy C library (it can be interfaced with callbacks and normal calls). So far, no problem, I used p/Invoke and all is fine. However, this library
writes to stdOut/stdError. :-((
Is there a way at service startup (or later) to redirect stdOut/stdError to files so as to prevent my Service to crash?

Thanks!

José

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: José Joye | last post by:
I have made a NT Service in c# and I need to use some features provided in a legacy C library (it can be interfaced with callbacks and normal calls). So far, no problem, I used p/Invoke and all is...
2
by: José Joye | last post by:
I have a library written in C (I do not have the source) and having some callbacks exported. It is currently not that stable and write to stdout and stderr :-(( The idea I have is to wrap it with...
4
by: Primo | last post by:
Hi, This problem has been frustrating me for days and I hope you experts can help me out. I am trying to run a command, which I would normally run from the command line, from within my C#...
2
by: Nadav | last post by:
Hi, Introduction: *************** I am trying to redirect stdout to a RichEdit control, this is done by initiating a StringWriter, associated it with a StringBuilder and setting the...
0
by: Chuck Gantz | last post by:
I have written two programs to test some stdin/stdout redirection ideas to eventually test a legacy console application writtn in C. One of the programs is a simple console app with some...
13
by: souissipro | last post by:
Hi, I have written a C program that does some of the functionalities mentionned in my previous topic posted some days ago. This shell should: 1- execute input commands from standard input,...
1
by: Hendrik van Rooyen | last post by:
I am writing a small application with a simple ascii based menu. The menu is used to test individual functions, and to change some timings. Otherwise the application just runs automatically,...
1
by: TP | last post by:
Hi everybody, I try to find a quick way to redirect the standard output of a Python command (for example: print "message") to a python variable "foobar". Ok, in this simple example, I could do...
2
by: TP | last post by:
Hi everybody, The following code does not redirect the output of os.system("ls") in a file: import sys, os saveout = sys.stdout fd = open( 'toto', 'w' ) sys.stdout = fd os.system( "ls" )
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.