I am trying to run a process which is invoked from either a C# or C++ program. The process has its standard output and standard input redirected to the program which invoked it. In this way, the calling program can control the child process programmatically. (The child process happens to be the MAME arcade emulator so I can run commands through the Lua console.) Things look about how I would expect them from the C++ program. I can read the output from the child process with the PeekNamedPipe() function. The characters are identical to what I see when I just run the process from the command line and observe the console. But when I run a similar C# program, the console output is not quite right. There are at least two issues. Using the Streamread read() method (the child process's stdout is directed to a stream), there are always about 30 "junk" characters that are read back before I see the characters I expect. Additionally, it appears that the characters at 16-bits (not 8-bit chars). (I can live with this, and I think I can convert them into 8-bit chars if I need to.) I have a strong suspicion that these characters are actually some low-level "under the hood" info about the string itself, like some kind of reflection data - maybe details about how it's encoded, length, etc. I just can't seems to figure out how to cleanly extract the "real" data out of the stream using C#. Can anyone make sense of this and give a hint of how I can get ASCII character data from the child process in C#? Thanks!
M
Member 14903335
@Member 14903335
Posts
-
C# vs C++ process standard out redirection differences -
Company namesAutomated name generators are affective and sometimes hillarious! https://www.domainhole.com/namespinner