Starting another program from inside a cf app

  • Thread starter Thread starter Chuck Hecht
  • Start date Start date
C

Chuck Hecht

I have tried to find documentation on this with no luck.
Does any one know where I can find it?

I want to either check to see if its running and if not start it

chuck
 
So, what do you know about it that would allow you to detect it and,
therefore, not start it again? I presume it can be started by someone
other than you? How does the program itself stop itself from being run
multiple times by the user? Main window title? Name of the EXE? Name of
an event or mutext it creates to make sure that there is only one instance
of it running?

Paul T.
 
Paul
I may not of been very clear. I want to have my app at startup look to see
if program "b" is running if it is great if not then I want to be able to
start program b then proceed on with running my app.

thanks
chuck

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
 
No, I understood that. Can the program be executed several times otherwise?
By the user, for example? If not, it may be that the program itself already
provides what you need. Otherwise, you'll need to have something
identifying about the program which you can detect. "The program" means
nothing to code running in the OS. Your brain understands what it means by
that, but the code that has to make something happen has to be a lot more
specific. As I said, if the main window is named something that you can
predict, use FindWindow() (I'm sure there's been a declaration for
P/Invoking that posted here before). If the only thing that's consistent is
the name of the EXE and you're feeling pretty confident that its name is
enough to uniquely identify it, you can use ToolHelp to see what processes
are running (that, also, has been discussed here before and it's wrapped in
OpenNETCF's Smart Device Framework, www.opennetcf.org). Ideally, the
program itself would give you something more unique, but, if you didn't
write it, you can only do so much...

Paul T.

Chuck Hecht said:
Paul
I may not of been very clear. I want to have my app at startup look to see
if program "b" is running if it is great if not then I want to be able to
start program b then proceed on with running my app.

thanks
chuck

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
So, what do you know about it that would allow you to detect it and,
therefore, not start it again? I presume it can be started by someone
other than you? How does the program itself stop itself from being run
multiple times by the user? Main window title? Name of the EXE? Name
of an event or mutext it creates to make sure that there is only one
instance of it running?

Paul T.
 
Chuck,

You can use the OpenNETCF.ToolHelp.ProcessEntry.GetProcesses() method to
return a list of running processes.

Use System.Diagnostics.Process class to start you app if its not running (if
using CF2.0) if not using CF2.0 then use the OpenNETCF.Diagnostics.Process
class (not too sure on that correct namespace, but SDF does have a Process
class to save you the time of writing your own.

You don't need to worry about mutex, just fire your app, if it is already
running the OS will bring it to the top of z-order.
--
Simon Hart
http://simonrhart.blogspot.com


Chuck Hecht said:
Paul
I may not of been very clear. I want to have my app at startup look to see
if program "b" is running if it is great if not then I want to be able to
start program b then proceed on with running my app.

thanks
chuck

"Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT
com> wrote in message news:[email protected]...
So, what do you know about it that would allow you to detect it and,
therefore, not start it again? I presume it can be started by someone
other than you? How does the program itself stop itself from being run
multiple times by the user? Main window title? Name of the EXE? Name of
an event or mutext it creates to make sure that there is only one instance
of it running?

Paul T.
 
You don't need to worry about mutex, just fire your app, if it is already
running the OS will bring it to the top of z-order.

Keep in mind that this only applies to PPC/WM apps. CE doesn't enforce this
behavior (and I've seen it fail with PPC apps in some cases too).


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
 
Back
Top