1
votes

Overview:
I need to detect if a given application is running in WinRT (aka "Metro") mode, by process/PID. Is there a good way of doing this?

Failed attempts and observations:

  • OpenProcess() and call Call GetPackageId() checking for != APPMODEL_ERROR_NO_PACKAGE: This seems to work for some processes while others such as Chrome when running in Metro mode fail the check.
  • Metro apps appear always be hosted (e.g. their parent) by svchost.exe

Any ideas? Please omit any "Don't do that" or "Why?" responses as they are not helpful to this particular question.

2
How are you deploying the application? Through the package?Dominic Hopton
Which application? The calling application (that needs this information) is a standard Windows service.NuSkooler
The application you are trying to validate. Because if the app isn't correctly deployed as a package, then it's not going to have any package informationDominic Hopton
I need to validate arbitrary PIDs. GetPackageId() is an attempt at a 'hack' to achieve my goal, but as stated is not helpful for many applications.NuSkooler
The point I was trying to make is that if GetPackageId fails, it's likely because it's an incorrectly deployed application. If you only need to validate correctly deployed applications -- e.g. those running in an app container, from the store, then your GetPackageId solution will likely succeed.Dominic Hopton

2 Answers

1
votes

IsImmersiveProcess would return true if the process is running in Metro Mode. Note, that if the detecting app is running as a service then this call always returns false.

0
votes

If the Metro app is running WWA Applet then get the command line arguement from the PID and see if it WWAHOST.exe. Not all metro apps are running as WWA applet for example, IE runs as a standalone exe in Metro mode.

This may sounds as a kludge but worked for me in detecting whether IE is in metro mode. The IE process in metro mode is still iexplore.exe. It's root parent process in Metro mode is Wininit.exe where in non metro mode is explorer.exe. So find the root parent PID for the IE's PID and then from the parent's PID get parent's process name then compare it against "Wininit.exe" or "Explorer.exe"