How do I know in a windows program if a process is running if I only know the exe file name ?
The process in question is TeamSpeak3 ts3client_win64.exe for 64 bit and ts3client_win32.exe for 32 bit.
I am using C++
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the
CreateToolhelp32Snapshotfunction to create a snapshot of the current process table, then use theProcess32FirstandProcess32Nextfunctions to iterate the snapshot. You can get the name for each executable file by looking at theszExeNamefield of thePROCESSENTRY32structure.See the MSDN example for a sample of how to use these functions.
The advantage of this approach is that, unlike any
EnumProcesses-based solution, it doesn’t suffer from race conditions: withEnumProcessesit can happen that a process gets destroyed after you finished enumerating the processes but before you got around to opening the process (or reading our the process executable name).