Process and Thread Function ...


IsWow64Message Function

Determines whether the last message read from the current thread's queue originated from a WOW64 process.

Syntax

C++
BOOL WINAPI IsWow64Message(void);

Parameters

This function has no parameters.

Return Value

The function returns TRUE if the last message read from the current thread's queue originated from a WOW64 process, and FALSE otherwise.

Remarks

This function is useful to helping you develop 64-bit native applications that can receive private messages sent from 32-bit client applications, if the messages are associated with data structures that contain pointer-dependent data. In these situations, you can call this function in your 64-bit native application to determine if the message originated from a WOW64 process and then thunk the message appropriately.

Examples

For compatibility with operating systems that do not support this function, call GetProcAddress to detect whether IsWow64Message is implemented in User32.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 User32.dll in current versions of 32-bit Windows also contains this function.

#include <windows.h>
#include <stdio.h>

typedef BOOL (WINAPI *LPFN_ISWOW64MESSAGE) (void);

LPFN_ISWOW64MESSAGE fnIsWow64Message;

BOOL IsWow64Msg()
{
    fnIsWow64Message = (LPFN_ISWOW64MESSAGE) GetProcAddress(
        LoadLibrary(TEXT("user32")), "IsWow64Message");
  
    if (NULL != fnIsWow64Message)
    {        
        return (fnIsWow64Message());
    }
    else return FALSE;
}

void main()
{
    if(IsWow64Msg())
        printf("Last message from 32-bit process\n");
    else if (NULL == fnIsWow64Message )
        printf("IsWow64Message not available (%d).\n", GetLastError());
    else printf("Last message from 64-bit process\n");
}

Requirements

Minimum supported clientWindows Vista, Windows XP with SP2
Minimum supported serverWindows Server 2008, Windows Server 2003 with SP1
HeaderWinuser.h (include Windows.h)
LibraryUser32.lib
DLLUser32.dll

See Also

GetNativeSystemInfo
IsWow64Process
WOW64

Send comments about this topic to Microsoft

Build date: 11/19/2009

Tags :


Page view tracker