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
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...
You could use GetPackageId and GetPackagePath and then read info about app from AppxManifest.xml
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
You can use GetCurrentProcessId to get process id.