Get the process ID of the running metro application

I want to get the process ID of a running Metro application programmatically using C ++ code from another process. I have static information about this application, such as name, full name, etc. What is an API? I can’t use EnumProcess because the running Metro application runs in the WWAHost.exe container of the application, so I can’t know which of the running WWAHost.exe processes actually launches my Metro application.

In the process handler, I noticed that the current directory of the WWAHost.exe process running my Metro application is similar to the installation location of the Metro application. Could this be a differentiating factor between all running application containers? If so, what is the way to get the current directory of another process?

To update, I have a solution regarding this in the msdn forums. Here is the link:

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

But the solution uses an undocumented mechanism for Windows to get the current directory of another process. I would like to use this solution only if there is no other way.

+1
source share
4 answers

Use GetForegroundWindow to get the current active window, then use GetWindowThreadProcessId to get the PID of the current window, and then valid if it is a WindowsStore application with IsImmersiveProcess strong>, then GetPackageId to get information about the application package, for example package name, version .. .

+2
source

You can use GetCurrentProcessId to get the process id.

+1
source

You want to call GetApplicationUserModelId for each WWAHost process.

The attached application allows you to pass the PID and get information about the application. For instance:

C:\src\GetAppInfo\Debug>GetAppInfo.exe 7400 Process 7400 (handle=00000044) Microsoft.BingWeather_8wekyb3d8bbwe!App 
+1
source

You can use GetPackageId and GetPackagePath , and then read the application information from AppxManifest.xml

0
source

Source: https://habr.com/ru/post/1485426/


All Articles