getting PID by name help

12/17/2016 00:32 iCraziE#1
I am not really sure how to start or word this.

I managed to find how to get the process ID by name, but i am having a new dilemma.

I need to get the process ID of an exe by the name of the exe, but if the exe is already open it needs to ignore those process ids.

For example.

If i have 6 "notepad.exe" open, i need my application to ignore the 6 already running and wait for a new one to open, then save that process id in a variable.

Can anyone help me with this?

Thanks.
12/17/2016 00:40 Jeoni#2
Just create a "list" (something like std::vector / std:: (unordered_)set) of running PIDs by the specified name on process startup. Then rapidly (well, would include a wait / sleep) recall your routine to get PIDs by name, try to find them in your list (std::find / std:: (unordered_)set::find) and on fail (if one PID is not in your list), use that PID. Done.
With best regards
Jeoni
12/17/2016 01:33 iCraziE#3
Yea I had a derp moment :D Thanks for the tips i got it now tho.
12/28/2016 11:17 Cyrex'#4
Another approach would be checking the "User time" or "Kernel time" of the main thread of the multiple instances.

[Only registered and activated users can see links. Click Here To Register...]