Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > C/C++
You last visited: Today at 05:42

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



getting PID by name help

Discussion on getting PID by name help within the C/C++ forum part of the Coders Den category.

Reply
 
Old   #1
 
iCraziE's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 456
Received Thanks: 218
getting PID by name help

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.
iCraziE is offline  
Old 12/17/2016, 00:40   #2


 
Jeoni's Avatar
 
elite*gold: 966
Join Date: Apr 2010
Posts: 1,105
Received Thanks: 681
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
Jeoni is offline  
Thanks
2 Users
Old 12/17/2016, 01:33   #3
 
iCraziE's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 456
Received Thanks: 218
Yea I had a derp moment Thanks for the tips i got it now tho.
iCraziE is offline  
Old 12/28/2016, 11:17   #4
 
elite*gold: 225
Join Date: Sep 2014
Posts: 334
Received Thanks: 460
Another approach would be checking the "User time" or "Kernel time" of the main thread of the multiple instances.

Cyrex' is offline  
Reply




All times are GMT +1. The time now is 05:44.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.