Start and Stop Process

  • Thread starter Thread starter Johann
  • Start date Start date
J

Johann

In the full framework another application could start and stop a process
through the System.Diagnostics.Process namespace, is it possible to do the
same thing with the compactframework?, how do I do it (any examples on the
web)?
Thx

Johann
 
The OpenNETCF SDF has Process class that emulates one available in the full
framework
 
Yes, but not an easy way. You'd need a launcher application which would
call SetStdioPathW(), then CreateProcess for the new process...

What are you planning to redirect it to?

Paul T.
 
Hi Paul,

thanks for your answer. The process starts an executable which makes output
to the console. I just need a way to get this output.

-Florian
 
Before calling CreateProcess(), call SetStdioPathW() and point that to a
driver that you write and ActivateDevice() on. Come up with a means to get
the data sent to the driver from it (you might pass it a window handle to
which PostMessage() would be used, or you might specify that you'll send a
DeviceIoControl() to the driver to retrieve the data, or whatever you want).
So, your code might look like this, roughly:

// Turn on the driver that will get the stdout stuff.
ActivateDevice( <my device driver's register path> );

// Get the old setting for the current process' stdout driver.
GetStdioPathW( stdout, oldStdOut, ... )

// Change the stdout driver to the special driver.
SetStdioPathW( stdout, <the device name of my driver, something like STD0:,
maybe> );

// Start the process. It will inherit the stdout destination from us.
CreateProcess( <the program that you want to run> );

// Restore our own stdout destinaton.
SetStdioPathW( stdout, oldStdOut );

// What you do here depends on how the rest of the code is written, but you
might
// want to remember to deactivate the driver, wait for the other program to
exit, or
// any number of things.

So, you'll have to write a driver and several P/Invoke declarations, as well
as design a means to get the accumulated data from the driver...

Paul T.
 
Back
Top