April 06, 2009

How To: Determine whether a 32-bits application is running on Windows 64-bits platform

WOW64 is the x86 emulator that allows 32-bit Windows-based applications to run seamlessly on 64-bit Windows.

Sample Code:

bool IsRunningOnWow64()
{
  BOOL bIsWow64 = FALSE;

  BOOL (WINAPI *fnIsWow64Process)(HANDLE, PBOOL);
  fnIsWow64Process = (BOOL(WINAPI*)(HANDLE, PBOOL))::GetProcAddress(
    ::GetModuleHandleW(L"kernel32"), "IsWow64Process");

  if(NULL != fnIsWow64Process)
    fnIsWow64Process(GetCurrentProcess(), &bIsWow64);

  return bIsWow64 ? true : false;
}

Reference on MSDN:
IsWow64Process Function