获取正在运行的Metro应用程序的进程ID [英] Get process id of a running metro app

查看:106
本文介绍了获取正在运行的Metro应用程序的进程ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过C ++代码从另一个进程中以编程方式获取正在运行的Metro应用程序的进程ID.我拥有该应用程序的静态信息,例如名称,全名等.执行此操作的API是什么? 我无法使用EnumProcess,因为正在运行的Metro App正在应用容器WWAHost.exe中运行,所以我不知道哪个正在运行的WWAHost.exe进程实际上正在运行 my Metro App.

I want to get the process id of a running Metro app programatically via C++ code, from another process. I have the static information of that app like name, full name etc. What is the API to do that? I can't use EnumProcess since the running Metro App is being run inside app container WWAHost.exe, so I can't know which of the running WWAHost.exe processes is actually running my Metro App.

在进程浏览器中,我注意到正在执行我的Metro App的WWAHost.exe进程的Current目录与Metro app安装位置相同.这可能是所有正在运行的应用程序容器之间的差异化因素吗?如果可以,如何获取另一个进程的当前目录?

In process explorer, I noticed that the Current directory of the WWAHost.exe process which is executing my Metro App is same as metro app install location. Could this be the differentiating factor between all the running app containers? If yes, what is the way to get current directory of another process?

要进行更新,我在msdn论坛上找到了一些与此有关的解决方案.这是链接:

To update, I have got some a solution regarding this on msdn forums. Here's the link:

http://social.msdn.microsoft.com/Forums/zh-CN/windowsgeneraldevelopmentissues/thread/c9665bf4-00e4-476c-badb-37126efd3f4b/

但是,该解决方案使用Windows上未公开的机制来获取另一个进程的当前目录.我只想在没有其他方法的情况下使用该解决方案.

But, the solution uses an undocumented mechanism on Windows to get current directory of another process. I would like to use that solution only if there's no other way.

推荐答案

使用 GetForegroundWindow 获取当前活动窗口,然后使用 GetWindowThreadProcessId 获取当前窗口的PID,然后有效,如果它是具有 IsImmersiveProcess 的WindowsStore应用程序,然后是 GetPackageId 以获取应用程序包信息,例如包名称,版本...

Use GetForegroundWindow to get current active window, after that use GetWindowThreadProcessId to get PID of current window, then valid if is a WindowsStore app with IsImmersiveProcess, then GetPackageId to get app package info, like package name, version...

这篇关于获取正在运行的Metro应用程序的进程ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆