I am using Visual C ++ from visual studio 2015 and I want to capture the moment when a process is closed. This is the outline of an initial code. I have consulted the Microsoft documentation but there are no examples to use this event with C ++.
#using <System.dll>
#include <stdlib.h>
#include <iostream>
using namespace System;
using namespace System::Diagnostics;
using namespace System::Threading;
int main() {
Process^ myProcess;
myProcess = Process::Start("Notepad.exe");
while (true) {
try {
myProcess->EnableRaisingEvents = true;
Console::WriteLine("Nombre {0}", myProcess->ProcessName);
Console::WriteLine("Inicio {0}, {1}", myProcess->StartTime, myProcess->EnableRaisingEvents);
Console::WriteLine("Fin {0}", myProcess->ExitTime);
}catch (Exception^ e){
Console::WriteLine("The following exception was raised: ");
Console::WriteLine(e->Message);
}
Thread::Sleep(2000);
}//Fin de while
}