S
Starbuck
I understand from postings by Paul Tobey and others that:
1) With CF2 we cannot use System.Diagnostics.Process to get a handle
to stdin and stdout.
2) OpenNETCF SDF no longer supports a Process class.
3) We need to use GetStdioPathW, SetStdPathW, CreateProcess, etc
I'm writing new code in C# 2.0 / VS2005 for CF2, where the goal is to
start a console .exe application and completely control the flow
to/from stdin/stdout. (And of course manage stderr if possible.) The
child process should run in a second thread to avoid deadlock issues
and to facilitate brutal process termination if required.
There are so many code segments available on this topic but each one
has problems - like failure to properly declare functions like
CreateProcess, or maybe incorrect usage of in/out values to that
function. I'd like to define once and for all exactly what is required
to accomplish this task, and I'll be happy to publish the entire
solution as open source when it's working. If publishing threatens the
IP of someone who generously provides information here (a constant
issue I face) then please let me know how we can work this out so that
the information can be made available to those who can use it without
impeding your ability to make a living.
While I'm coding in C#, I can easily translate VB.NET or just
reference a VB.NET DLL for the process interaction. I've seen some
C++ code on this but nothing that I've been able to translate to
functional C#. So C# is preferred, but since I'm trying to learn how
it all works, any language providing working functionality of various
aspects of this will be welcome.
Where am I getting stuck? There are subtle differences in the way
people are setting the SECURITY_ATTRIBUTES struct and STARTUPINFO
(which personally I prefer to refer to as STARTUP_INFO but the
standard seems to be without the underscore). For example, some
people create a memory pointer for STARTUPINFO and others use
IntPtr.Zero for that value when calling CreatePipe. Some people use
SetHandleInformation to make sure a pipe isn't inherited, some don't.
Following the "teach a man to fish..." saying, I'm not looking for
"fish" and I'm quite willing to learn how things work, but doing this
entirely on my own is taking way too long. I need help, I'd like to
rely on colleagues here to guide the process, and if anyone can help,
I'd like to contribute this aspect of my good fortune back to the
community.
So before I start asking code questions in this thread, my first
questions are these:
1) Is this any easier in CF 3.5 or VS 2008? I'm still coding for
PPC2003 at the moment but I can set a minimum supported WinCE level if
required.
2) Is a complete solution for this already available somewhere? Even
an internal project that someone can provide (oops, asking for a fish)
that I can rip up (and learn in the process) and publish as a basic
skeleton?
3) Is there a better approach to learning how to create this specific
environment? A book that goes through this in detail?
Thank you very much!!
(Email welcome, disposable address will be changed as spam becomes a
problem)
1) With CF2 we cannot use System.Diagnostics.Process to get a handle
to stdin and stdout.
2) OpenNETCF SDF no longer supports a Process class.
3) We need to use GetStdioPathW, SetStdPathW, CreateProcess, etc
I'm writing new code in C# 2.0 / VS2005 for CF2, where the goal is to
start a console .exe application and completely control the flow
to/from stdin/stdout. (And of course manage stderr if possible.) The
child process should run in a second thread to avoid deadlock issues
and to facilitate brutal process termination if required.
There are so many code segments available on this topic but each one
has problems - like failure to properly declare functions like
CreateProcess, or maybe incorrect usage of in/out values to that
function. I'd like to define once and for all exactly what is required
to accomplish this task, and I'll be happy to publish the entire
solution as open source when it's working. If publishing threatens the
IP of someone who generously provides information here (a constant
issue I face) then please let me know how we can work this out so that
the information can be made available to those who can use it without
impeding your ability to make a living.
While I'm coding in C#, I can easily translate VB.NET or just
reference a VB.NET DLL for the process interaction. I've seen some
C++ code on this but nothing that I've been able to translate to
functional C#. So C# is preferred, but since I'm trying to learn how
it all works, any language providing working functionality of various
aspects of this will be welcome.
Where am I getting stuck? There are subtle differences in the way
people are setting the SECURITY_ATTRIBUTES struct and STARTUPINFO
(which personally I prefer to refer to as STARTUP_INFO but the
standard seems to be without the underscore). For example, some
people create a memory pointer for STARTUPINFO and others use
IntPtr.Zero for that value when calling CreatePipe. Some people use
SetHandleInformation to make sure a pipe isn't inherited, some don't.
Following the "teach a man to fish..." saying, I'm not looking for
"fish" and I'm quite willing to learn how things work, but doing this
entirely on my own is taking way too long. I need help, I'd like to
rely on colleagues here to guide the process, and if anyone can help,
I'd like to contribute this aspect of my good fortune back to the
community.
So before I start asking code questions in this thread, my first
questions are these:
1) Is this any easier in CF 3.5 or VS 2008? I'm still coding for
PPC2003 at the moment but I can set a minimum supported WinCE level if
required.
2) Is a complete solution for this already available somewhere? Even
an internal project that someone can provide (oops, asking for a fish)
that I can rip up (and learn in the process) and publish as a basic
skeleton?
3) Is there a better approach to learning how to create this specific
environment? A book that goes through this in detail?
Thank you very much!!
(Email welcome, disposable address will be changed as spam becomes a
problem)