Detecting Windows 8 Metro application
Detecting Windows 8 Metro application
Is there any way (official or by using any kind of telltale signs) to determine if the current process is Metro or Desktop application?
Re: Detecting Windows 8 Metro application
Good question. I didn't need this myself yet, so I don't know how to do that. I'm sure there is a way, but I don't know how. Would have to do a google search myself to find out...
-
- Posts: 39
- Joined: Fri Jan 26, 2007 11:12 am
Re: Detecting Windows 8 Metro application
Here's my 'Metro' detection routine...
Code: Select all
HMODULE hApp = GetModuleHandleA(NULL);
if (IsMetro(hApp))
. . .
/*
** IsMetro - return if the process is a Metro/Modern-UI app
***************************************************************************************************/
static BOOL IsMetro(HMODULE hApp)
{
IMAGE_DOS_HEADER ImageDosHeader;
IMAGE_OPTIONAL_HEADER32 ImageOptionalHeader;
BOOL bRet;
CopyMemory(&ImageDosHeader, hApp, sizeof(ImageDosHeader));
CopyMemory(&ImageOptionalHeader, ((BYTE *)hApp + sizeof(DWORD) + ImageDosHeader.e_lfanew + sizeof(IMAGE_FILE_HEADER)), sizeof(ImageOptionalHeader));
bRet = ImageOptionalHeader.DllCharacteristics & 4096; // Metro/Modern-UI app flag
if (bRet)
dbg("Metro/Modern-UI app");
return bRet;
}
-
- Posts: 39
- Joined: Fri Jan 26, 2007 11:12 am
Re: Detecting Windows 8 Metro application
^ doesn't seem to work any more.
Instead, use something akin to the following. Caveat: explorer and taskmgr report as immersive... bing maps' map.exe starts non-immersive but switches to immersive shortly after.
Instead, use something akin to the following. Caveat: explorer and taskmgr report as immersive... bing maps' map.exe starts non-immersive but switches to immersive shortly after.
Code: Select all
typedef BOOL (WINAPI * t_IsImmersiveProcess)(HANDLE hProcess);
t_IsImmersiveProcess fn_IsImmersiveProcess = (t_IsImmersiveProcess)GetProcAddress(hUser32, "IsImmersiveProcess");
if (fn_IsImmersiveProcess)
if (fn_IsImmersiveProcess(GetCurrentProcess()))
{