How to check if a process is running or not using C++

前端 未结 3 1337
情书的邮戳
情书的邮戳 2021-01-14 21:28

I should not display certain context menu options if one process is not running?. I am checking if the process is running or not using the process name.

But the iss

相关标签:
3条回答
  • 2021-01-14 21:52

    Using WMI to interrogate instances of Win32_Process allows you to check the fullpath of the running processes for a match on the one you need to see.

    0 讨论(0)
  • 2021-01-14 21:52

    Are you the author of the process in question? If so, a more robust design would be to use IPC to interrogate the process directly. That way, you don't necessarily have to poll and you don't have irritating issues such as what happens if you detect the process, create the context menu and then the process goes down?

    0 讨论(0)
  • 2021-01-14 21:59

    EnumProcesses is the other way to enumerate active processes.

    The difference is that you need to allocate the space for PIDs,call EnumProcesses, open each process with PROCESS_QUERY_INFORMATION access flag and then call GetProcessImageFileName on it's handle and do the comparison.

    0 讨论(0)
提交回复
热议问题