8 out of 18 rated this helpful - Rate this topic

IsWow64Process function

Applies to: desktop apps only

Determines whether the specified process is running under WOW64.

Syntax

BOOL WINAPI IsWow64Process(
  __in   HANDLE hProcess,
  __out  PBOOL Wow64Process
);

Parameters

hProcess [in]

A handle to the process. The handle must have the PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION access right. For more information, see Process Security and Access Rights.

Windows Server 2003 and Windows XP:  The handle must have the PROCESS_QUERY_INFORMATION access right.
Wow64Process [out]

A pointer to a value that is set to TRUE if the process is running under WOW64. If the process is running under 32-bit Windows, the value is set to FALSE. If the process is a 64-bit application running under 64-bit Windows, the value is also set to FALSE.

Return value

If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

To compile an application that uses this function, define _WIN32_WINNT as 0x0501 or later. For more information, see Using the Windows Headers.

Examples

For compatibility with operating systems that do not support this function, call GetProcAddress to detect whether IsWow64Process is implemented in Kernel32.dll. If GetProcAddress succeeds, it is safe to call this function. Otherwise, WOW64 is not present. Note that this technique is not a reliable way to detect whether the operating system is a 64-bit version of Windows because the Kernel32.dll in current versions of 32-bit Windows also contains this function.


#include <windows.h>
#include <tchar.h>

typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);

LPFN_ISWOW64PROCESS fnIsWow64Process;

BOOL IsWow64()
{
    BOOL bIsWow64 = FALSE;

    //IsWow64Process is not available on all supported versions of Windows.
    //Use GetModuleHandle to get a handle to the DLL that contains the function
    //and GetProcAddress to get a pointer to the function if available.

    fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
        GetModuleHandle(TEXT("kernel32")),"IsWow64Process");

    if(NULL != fnIsWow64Process)
    {
        if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
        {
            //handle error
        }
    }
    return bIsWow64;
}

int main( void )
{
    if(IsWow64())
        _tprintf(TEXT("The process is running under WOW64.\n"));
    else
        _tprintf(TEXT("The process is not running under WOW64.\n"));

    return 0;
}


Requirements

Minimum supported client

Windows Vista, Windows XP with SP2

Minimum supported server

Windows Server 2008, Windows Server 2003 with SP1

Header

WinBase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

GetNativeSystemInfo
IsWow64Message
WOW64

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Permission denied...
Hi! So, how does a .NET program get that PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION access right? Lots of Greetings! Volker
The easiest way to determine in C++ if the operating system is a 64 Bit operating system
BOOL b_64BitOpSys;

#ifdef _WIN64
    b_64BitOpSys = TRUE
#else
    IsWow64Process(GetCurrentProcess(), &b_64BitOpSys);
#endif

Note: A 32 Bit compiled process runs always as Wow64 process on 64 Bit Windows!

This doesn't work - b_64BitOpSys is ALWAYS TRUE if _WIN64 is defined on the DEVELOPMENT system.
For VB6 :)
Private Type SYSTEM_INFO
    dwOemID As Long
    dwPageSize As Long
    lpMinimumApplicationAddress As Long
    lpMaximumApplicationAddress As Long
    dwActiveProcessorMask As Long
    dwNumberOrfProcessors As Long
    dwProcessorType As Long
    dwAllocationGranularity As Long
    dwReserved As Long
End Type

Private Declare Function IsWow64Process Lib "kernel32" (ByVal hProcess As Long, ByRef Wow64Process As Long) As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Sub GetNativeSystemInfo Lib "kernel32" (lpSystemInfo As SYSTEM_INFO)

Private Sub Form_Load()
    'KPD-Team 2001
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
    Dim Ret As Long
    IsWow64Process GetCurrentProcess, Ret
    If Ret = 0 Then
        MsgBox "This application is not running on an x86 emulator for a 64-bit computer!"
    Else
        Dim SysInfo64 As SYSTEM_INFO
        GetNativeSystemInfo SysInfo64
        MsgBox "Number of processors on your 64-bit system: " + CStr(SysInfo64.dwNumberOrfProcessors)
    End If
End Sub
Under .NET 4.0 Framework
The .NET 4.0 framework now provides information in System.Environment Class.
System.Environment.Is64BitOperatingSystem
System.Environment.Is64BitProcess
VB.NET Determine x32 or x64 platform example

The MSDN example determines if your running under WOW64 this can't be used to determine if the OS is x64 because this entry point exists in Kernel32 XP x32 SP2 +


GetNativeSystemInfo Example VB.NET

Private Const PROCESSOR_ARCHITECTURE_INTEL = 0
Private Const PROCESSOR_ARCHITECTURE_IA64 = 6
Private Const PROCESSOR_ARCHITECTURE_AMD64 = 9
Private Const PROCESSOR_ARCHITECTURE_UNKNOWN = &HFFFF

<StructLayout(LayoutKind.Sequential)> _
Public Structure SYSTEM_INFO
Dim wProcessorArchitecture As Short
Dim wReserved As Short
Dim dwPageSize As Integer
Dim lpMinimumApplicationAddress As IntPtr
Dim lpMaximumApplicationAddress As IntPtr
Dim dwActiveProcessorMask As IntPtr
Dim dwNumberOfProcessors As Integer
Dim dwProcessorType As Integer
Dim dwAllocationGranularity As Integer
Dim wProcessorLevel As Short
Dim wProcessorRevision As Short
End Structure


Declare Auto Sub GetNativeSystemInfo Lib "kernel32.dll" (ByRef lpSystemInfo As SYSTEM_INFO)

Public Shared Function IsPlatformX64() As Boolean
Dim sysInfo As SYSTEM_INFO
Dim osv As OperatingSystem
Dim fOk As Boolean = False
osv = Environment.OSVersion
If osv.Version.Major > 5 Or (osv.Version.Major = 5 And osv.Version.Minor >= 1) Then
GetNativeSystemInfo(sysInfo)
Select Case sysInfo.wProcessorArchitecture
Case PROCESSOR_ARCHITECTURE_IA64, PROCESSOR_ARCHITECTURE_AMD64
fOk = True
End Select
End If
Return fOk
End Function







IntPtr Example VB.NET (AnyCPU compiled)

Public Shared Function IsPlatformX64() As Boolean
Dim fOk As Boolean = False
If IntPtr.Size = 8 Then
fOk = True
End If
Return fOk
End Function