简体   繁体   English

处理上一次运行的进程win32

[英]Handle to last run process win32

How do I get HANDLE to last run process by user? 如何获得用户上一次运行处理的句柄? My Application will be running, has started one process using CreateProcess() or ShellExecute() , and then user comes and executes another, independent process, externally. 我的应用程序将正在运行,并使用CreateProcess()或ShellExecute()启动了一个进程,然后用户来从外部执行另一个独立的进程。 Forget about user must be doing this and that. 忘记用户必须要做的事情。 We are sure user will run one and only one application at exactly this point. 我们确定用户此时将仅运行一个应用程序。

How do I get HANDLE to this process? 如何处理此过程? I won't have its name or id or anything else. 我不会有它的名称或ID或其他任何名称。 All I know is it is being run after my application started executing or rather after creating a process using one of the mentioned method above. 我所知道的是它是在我的应用程序开始执行之后或者正在使用上述方法之一创建进程之后运行的。

Any Help is appreciated. 任何帮助表示赞赏。

You can use the Process Enumeration APIs to enumerate the processes in the system, and for each use the GetProcessTimes() function to find out when the process started. 您可以使用Process Enumeration API枚举系统中的进程,对于每个进程,都可以使用GetProcessTimes()函数来确定进程何时开始。 Then it's just a matter of putting them into a map or otherwise sorting them to find the most recently-started one. 然后,只需将它们放入地图中或对它们进行排序以找到最近开始的地图即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM