Terminate process when start new one with the same name

  • Thread starter Thread starter Zuhlik
  • Start date Start date
Z

Zuhlik

Guest
I'm trying to write a simple console application in C ++ that displays a list of all processes and saves them to a text file - and that's not a problem using the below handle:

hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
proc32.dwSize = sizeof(PROCESSENTRY32);
Than I would like to run a second instance of the same process (executable file with the same name) after double-clicking or command from the console, that closes the already running - the new one is exactly the same (display processes list) and is closed when the next one is started. How could it be done in the easiest way?

Continue reading...
 
Back
Top