I have an app A, that injects a DLL into a certain process P. If the P is not running, I start it using CreateProcessEx. Now A and P are both running. Then P is closed by the user (I can catch this event - see "easiest way to know if a target app is closed"), and A is still running. Then P is restarted by the user. Now A should really re-inject the DLL into the new process P. But what is the easiest way to find out if P is restarted based on the exe-name?
There's just one easy way and that is polling (= ugly). There is no easy *and* nice way that I know of. Maybe WMI could notify you about new processes, but I've never tried that yet - and it doesn't work in all OSs by default.