Reputation: 13
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.
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?
To update, I have got some a solution regarding this on msdn forums. Here's the link:
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.
Upvotes: 1
Views: 4184
Reputation: 31
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...
Upvotes: 2
Reputation: 57075
You want to call GetApplicationUserModelId on each WWAHost process.
The sample application provided allows you to pass in a PID and get back the information about the app. For instance:
C:\src\GetAppInfo\Debug>GetAppInfo.exe 7400
Process 7400 (handle=00000044)
Microsoft.BingWeather_8wekyb3d8bbwe!App
Upvotes: 2
Reputation: 1
You could use GetPackageId and GetPackagePath and then read info about app from AppxManifest.xml
Upvotes: 0