|
-
August 6th, 2005, 03:27 PM
#1
How to kill a process ?
Hi,
How can I kill a process in MFC?
It's not a process that I have created, and all I know is the process name as it appears in "Windows task manager"...
-
August 6th, 2005, 03:45 PM
#2
Re: How to kill a process ?
 Originally Posted by yaniv_av
How can I kill a process in MFC?
It's not a process that I have created, and all I know is the process name as it appears in "Windows task manager"...
Why would you want to do this... ?
(as the process is not one of your creation...)
-
August 6th, 2005, 03:52 PM
#3
Re: How to kill a process ?
 Originally Posted by Siddhartha
Why would you want to do this... ?
(as the process is not one of your creation...)
Well, I'll be more specific.
I'm using some OCX from third-party. The OCX create the process.
The problem is that even when I'm using the "Exit" function of the OCX - It won't kill the process it had created...
So, if I'm using my app several times, I have several processes that are not kills from windows processes...
So I want to create some app that go throght the active windows processes, and kill all the processes with the OCX process name...
-
August 6th, 2005, 03:59 PM
#4
Re: How to kill a process ?
 Originally Posted by yaniv_av
Well, I'll be more specific.
I'm using some OCX from third-party. The OCX create the process.
The problem is that even when I'm using the "Exit" function of the OCX - It won't kill the process it had created...
So, if I'm using my app several times, I have several processes that are not kills from windows processes...
So I want to create some app that go throght the active windows processes, and kill all the processes with the OCX process name...
The OCX is a COM Component.
Perhaps, it terminates the processes it creates when the OCX itself is unloaded.
As COM Components are reference counted, they are not simply unloaded when one client stops using them, but they get unloaded only when *all* clients stop using them.
Hence, terminating that process (by force) is certainly going to cause unknown problems to the system, and to the clients of that OCX (other than yours.)
In addition, a reference count bug can result in the OCX stay loaded for longer that its supposed to.
I would recommend you to look up your usage of this Component.
It is possible to detect and terminate processes, but in this case I would strongly discourage it as -
- You are not aware of the impact of this action.
- Terminating a process may leave many resources (like files opened, etc) in an unknown (read: unstable) state.
-
August 6th, 2005, 04:08 PM
#5
Re: How to kill a process ?
 Originally Posted by Siddhartha
The OCX is a COM Component.
Perhaps, it terminates the processes it creates when the OCX itself is unloaded.
As COM Components are reference counted, they are not simply unloaded when one client stops using them, but they get unloaded only when *all* clients stop using them.
Hence, terminating that process (by force) is certainly going to cause unknown problems to the system, and to the clients of that OCX (other than yours.)
In addition, a reference count bug can result in the OCX stay loaded for longer that its supposed to.
I would recommend you to look up your usage of this Component.
It is possible to detect and terminate processes, but in this case I would strongly discourage it as -
- You are not aware of the impact of this action.
- Terminating a process may leave many resources (like files opened, etc) in an unknown (read: unstable) state.
All of that is true, but what can I do ?
I'm starting that OCX with "Init" function, and try to end it with "Exit" function (in the DTOR) - but the COM object is still up.
And I 100% sure that my app is the only client for that OCX ...
-
August 6th, 2005, 04:13 PM
#6
Re: How to kill a process ?
 Originally Posted by yaniv_av
All of that is true, but what can I do ?
I'm starting that OCX with "Init" function, and try to end it with "Exit" function (in the DTOR) - but the COM object is still up.
And I 100% sure that my app is the only client for that OCX ...
Your Client is C++, right?
I have not worked with OCX-s. But, a COM Component is to be instantiated by a call to CoCreateInstance.
So, I dont understand this Init function!
To answer your question, look up -
You need to tweak the former, and use the latter.
(But, attempt a workaround first...)
-
August 6th, 2005, 04:17 PM
#7
Re: How to kill a process ?
 Originally Posted by Siddhartha
Your Client is C++, right?
I have not worked with OCX-s. But, a COM Component is to be instantiated by a call to CoCreateInstance.
So, I dont understand this Init function!
To answer your question, look up -
You need to tweak the former, and use the latter.
(But, attempt a workaround first...)
I'm using that OCX by put a static member function in my dialog (just like adding a button to a dialog). So I'm not using CoCreateInstance function.
The "Init" function initiated some of the OCX properties...
10x! - I'll look at those links.
-
August 7th, 2005, 12:26 PM
#8
Re: How to kill a process ?
 Originally Posted by yaniv_av
I'm using that OCX by put a static member function in my dialog (just like adding a button to a dialog). So I'm not using CoCreateInstance function.
The "Init" function initiated some of the OCX properties...
10x! - I'll look at those links.
Heed the advice of the others - don't shut something down unless you really know it's safe to do so (and understand the ramifications involved). If so then try this:
http://support.microsoft.com/kb/q178893/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|