Calling CreateProcess repeatedly

  • Thread starter Thread starter Peter B
  • Start date Start date
P

Peter B

Is it ok to call CreateProcess(...) (from OpenNETCF.org WinAPI) repeatedly
with the same application as argument. I am starting peghelp.exe from
different forms (via a global class). I.e. what happens when I do this? Any
good information I could read up on?

The global method I use from different forms:
public static void ShowHelp( string tag )
{
OpenNETCF.WinAPI.Core.CreateProcess("peghelp.exe", tag);
}

regards,

Peter
 
Well, there's a limit in Windows CE on the number of running processes, so
it will fail eventually, if some of those instances don't exit. You can
probably read on MSDN some of the general information about the OS. You
don't really want to have 20 or 30 copies of peghelp running, do you?

Paul T.
 
Hi Paul, thanks for your reply!

No I don't want 30 copies of peghelp running :-) I might have missed to
inform you that I am using PocketPC2003 and I was under the impression that
you can run only one instance of a application at any time?!? This may be a
..NET Compact Framework feature though, and since I am calling native code it
might not apply here...?

I could of course save the IntPtr to the first process I create and reuse
it. I'll have a look to see if there is a method that can take the IntPtr
and an argument to reuse the same PegHelp instance (something like
RecallProcess( IntPtr, argument)).

/ Peter
 
I guess that what's confusing is that I don't understand what you are really
trying to achieve. You have an instance of peghelp running and you want to
change which page is displayed by it in response to some sort of user
action?

I don't have a PPC, so I don't know what would happen, but unless the
application itself makes sure that there is only one instance of it running,
you can run as many as you have process slots and memory for, in the general
Windows CE case...

Paul T.
 
Most "well-designed" Pocket PC applications will simply check for a running
instance upon startup and activate it then exit. So, no harm should be in
launching the process repeatedly. With peghelp, this is probably the only
way to ensure the parameters are passed correctly to the running instance
too
 
In the case of peghelp.exe this is perfectly safe. The application only
allows one running instance and will switch to the file/topic specified in
the argument. This is a perfectly acceptable (only way) of programmatically
bringing up different help topics based on the context of your application -
native applications will do just the same.

For example you may use a different topic per form, or store the topic name
in a variable which you can change based on the current options set by the
user. How you choose this depends entirely on your requirements. If you pass
in the topic name which is currently open in peghelp, then you will bring
the help window to the front.

Peter
 
Thanks for the replies Alex and Peter!

So now I know this way of calling peghelp should be safe, now to the
"actual" problem :)

I think I will create a new thread for this as there is quite a lot of
information and the topic is slightly different. Please read "What does this
error mean?"

thanks again guys!!

// Peter
 
Back
Top