Tip - How to Terminate all the instances of a Process through code
Details - By the below shared lines of codes one can terminate all the instances of a process. CreateToolhelp32Snapshot API is used to take the snapshot of all the processes and threads in the system. The process which is to be terminated is identified from the snapshot using the Process Name. Then the process object is accessed using OpenProcess API and terminated using TerminateProcess(). The CreateToolhelp32Snapshot API not only takes a snapshot of the processes, but also the heaps, modules, and threads used by the processes.
Details - By the below shared lines of codes one can terminate all the instances of a process. CreateToolhelp32Snapshot API is used to take the snapshot of all the processes and threads in the system. The process which is to be terminated is identified from the snapshot using the Process Name. Then the process object is accessed using OpenProcess API and terminated using TerminateProcess(). The CreateToolhelp32Snapshot API not only takes a snapshot of the processes, but also the heaps, modules, and threads used by the processes.
Reference -
http://msdn.microsoft.com/en-us/library/ms682489(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms684834(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms682489(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms684834(VS.85).aspx
Posted by - Sobhita Mercy E
No comments:
Post a Comment