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"...
Printable View
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"...
Why would you want to do this... ?Quote:
Originally Posted by yaniv_av
(as the process is not one of your creation...)
Well, I'll be more specific.Quote:
Originally Posted by Siddhartha
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.Quote:
Originally Posted by yaniv_av
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 ? :confused:Quote:
Originally Posted by Siddhartha
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?Quote:
Originally Posted by yaniv_av
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.Quote:
Originally Posted by Siddhartha
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:Quote:
Originally Posted by yaniv_av
http://support.microsoft.com/kb/q178893/