OpenNetCF - Killing Local Processes

  • Thread starter Paul [Paradise Solutions]
  • Start date
P

Paul [Paradise Solutions]

Hi All

I've been looking at the OpenNetCF and it's Process Class - I see lots
of ways to start and control a process, but is there a way to kill a
process that was not started by you? By that, I mean that you don't
have a ProcessID, so GetProcessByID is out and there doesn't seemt to be
a way to get an ID from an application/window title.

Anyone have any suggestions?


Many thanks


Paul
 
P

Paul G. Tobey [eMVP]

You can enumerate all of the processes in the system with toolhelp
functions. I don't know what portion of those might be implemented in SDF,
but I think at least one or two were.

Don't forget that calling TerminateProcess is a very, very serious matter
and should be done only as a final resort, expecting the system to be left
in a semi-stable state.

Paul T.
 
P

Paul [Paradise Solutions]

My requirement is that I need to shut down another of my own
applications - there must not be any need for user intervention.
Basicly, I want to do programaticly the same as going into Running
Programs in Settings on a PPC.
Thanks for the info and I accept your warnings, but at present it's the
only way I can find to do what I need.


Many thanks

Paul
 
D

Daniel Moth

Just a thought. If it is one of your own, why not tell it (e.g. with a named
event) to shut down itself?

Cheers
Daniel
 
P

Paul G. Tobey [eMVP]

You can do that by having a know way of sending a message to that
application, in response to which it can just exit. Use
RegisterWindowMessage() with the same message name in both applications.
When the message arrives in the one to be exited, exit it! Send it using
SendMessage( HWND_BROADCAST, ... ) from the other one. There is
*absolutely, positively* no good reason why you should have to use
TerminateProcess on a program for which you have the source and know that
you'll need to cause an exit from.

Paul T.
 
P

Paul [Paradise Solutions]

Errr... sure... you can only utilize a method if you know about it and
I've not had a need to do anything like this before.

I now do but there's no need to give your self an ulcer over it - there
are far more important things in the world to do that.

Thanks for the heads up, I'll be looking into it Monday.


Paul
You can do that by having a know way of sending a message to that
application, in response to which it can just exit. Use
RegisterWindowMessage() with the same message name in both applications.
When the message arrives in the one to be exited, exit it! Send it using
SendMessage( HWND_BROADCAST, ... ) from the other one. There is
*absolutely, positively* no good reason why you should have to use
TerminateProcess on a program for which you have the source and know that
you'll need to cause an exit from.

Paul T.

My requirement is that I need to shut down another of my own
applications - there must not be any need for user intervention. Basicly,
I want to do programaticly the same as going into Running Programs in
Settings on a PPC.
Thanks for the info and I accept your warnings, but at present it's the
only way I can find to do what I need.


Many thanks

Paul

Paul G. Tobey [eMVP] wrote:

You can enumerate all of the processes in the system with toolhelp
functions. I don't know what portion of those might be implemented in
SDF, but I think at least one or two were.

Don't forget that calling TerminateProcess is a very, very serious matter
and should be done only as a final resort, expecting the system to be
left in a semi-stable state.

Paul T.

message

Hi All

I've been looking at the OpenNetCF and it's Process Class - I see lots of
ways to start and control a process, but is there a way to kill a process
that was not started by you? By that, I mean that you don't have a
ProcessID, so GetProcessByID is out and there doesn't seemt to be a way
to get an ID from an application/window title.

Anyone have any suggestions?


Many thanks


Paul
 
P

Peter Foot [MVP]

If you want to emulate the functionality of the running programs applet you
can send a WM_CLOSE message to your specific window (rather than
broadcasting a special message), you can use FindWindow to determine the
windowhandle of your application from its window caption. This is how the
control panel applet closes applications.

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Paul said:
Errr... sure... you can only utilize a method if you know about it and
I've not had a need to do anything like this before.

I now do but there's no need to give your self an ulcer over it - there
are far more important things in the world to do that.

Thanks for the heads up, I'll be looking into it Monday.


Paul
You can do that by having a know way of sending a message to that
application, in response to which it can just exit. Use
RegisterWindowMessage() with the same message name in both applications.
When the message arrives in the one to be exited, exit it! Send it using
SendMessage( HWND_BROADCAST, ... ) from the other one. There is
*absolutely, positively* no good reason why you should have to use
TerminateProcess on a program for which you have the source and know that
you'll need to cause an exit from.

Paul T.

My requirement is that I need to shut down another of my own
applications - there must not be any need for user intervention. Basicly,
I want to do programaticly the same as going into Running Programs in
Settings on a PPC.
Thanks for the info and I accept your warnings, but at present it's the
only way I can find to do what I need.


Many thanks

Paul

Paul G. Tobey [eMVP] wrote:


You can enumerate all of the processes in the system with toolhelp
functions. I don't know what portion of those might be implemented in
SDF, but I think at least one or two were.

Don't forget that calling TerminateProcess is a very, very serious
matter and should be done only as a final resort, expecting the system
to be left in a semi-stable state.

Paul T.

message

Hi All

I've been looking at the OpenNetCF and it's Process Class - I see lots
of ways to start and control a process, but is there a way to kill a
process that was not started by you? By that, I mean that you don't
have a ProcessID, so GetProcessByID is out and there doesn't seemt to
be a way to get an ID from an application/window title.

Anyone have any suggestions?


Many thanks


Paul
 
P

Paul G. Tobey [eMVP]

I'm not sure where you're coming from. All I did was give you a possible
solution and strongly discourage you from using TerminateProcess.

Paul T.

Paul said:
Errr... sure... you can only utilize a method if you know about it and
I've not had a need to do anything like this before.

I now do but there's no need to give your self an ulcer over it - there
are far more important things in the world to do that.

Thanks for the heads up, I'll be looking into it Monday.


Paul
You can do that by having a know way of sending a message to that
application, in response to which it can just exit. Use
RegisterWindowMessage() with the same message name in both applications.
When the message arrives in the one to be exited, exit it! Send it using
SendMessage( HWND_BROADCAST, ... ) from the other one. There is
*absolutely, positively* no good reason why you should have to use
TerminateProcess on a program for which you have the source and know that
you'll need to cause an exit from.

Paul T.

My requirement is that I need to shut down another of my own
applications - there must not be any need for user intervention. Basicly,
I want to do programaticly the same as going into Running Programs in
Settings on a PPC.
Thanks for the info and I accept your warnings, but at present it's the
only way I can find to do what I need.


Many thanks

Paul

Paul G. Tobey [eMVP] wrote:


You can enumerate all of the processes in the system with toolhelp
functions. I don't know what portion of those might be implemented in
SDF, but I think at least one or two were.

Don't forget that calling TerminateProcess is a very, very serious
matter and should be done only as a final resort, expecting the system
to be left in a semi-stable state.

Paul T.

message

Hi All

I've been looking at the OpenNetCF and it's Process Class - I see lots
of ways to start and control a process, but is there a way to kill a
process that was not started by you? By that, I mean that you don't
have a ProcessID, so GetProcessByID is out and there doesn't seemt to
be a way to get an ID from an application/window title.

Anyone have any suggestions?


Many thanks


Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top