isWow64Message 函数 (winuser.h)

确定从当前线程队列中读取的最后一条消息是否源自 WOW64 进程。

语法

BOOL IsWow64Message();

返回值

如果从当前线程的队列中读取的最后一条消息源自 WOW64 进程,则函数返回 TRUE,否则返回 FALSE。

注解

如果消息与包含指针依赖数据的数据结构相关联,则此函数有助于开发可接收从 32 位客户端应用程序发送的专用消息的 64 位本机应用程序。 在这些情况下,可以在 64 位本机应用程序中调用此函数,以确定消息是否源自 WOW64 进程,然后相应地发送消息。

示例

为了与不支持此函数的操作系统兼容,请调用 GetProcAddress 以检测 isWow64Message 是否在 User32.dll 中实现。 如果 GetProcAddress 成功,则调用此函数是安全的。 否则,WOW64 不存在。 请注意,此方法不是检测操作系统是否为 64 位版本的 Windows 的可靠方法,因为当前版本的 32 位 Windows 中的 User32.dll 也包含此函数。

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

typedef BOOL (WINAPI *LPFN_ISWOW64MESSAGE) (void);

LPFN_ISWOW64MESSAGE fnIsWow64Message;

BOOL IsWow64Msg()
{
    // IsWow64Message is not available on all supported versions of Windows
    // Use LoadLibrary to ensure that the DLL containing the function is loaded
    // and GetProcAddress to get a pointer to the function if available.

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

int main( void )
{
    if(IsWow64Msg())
    {
        _tprintf(TEXT("The last message was from a 32-bit process.\n"));
    }
    else if (NULL == fnIsWow64Message )
    {
        _tprintf(TEXT("The IsWow64Message function is not available (%d).\n"), GetLastError());
    }
    else 
    {
        _tprintf(TEXT("The last message was from a 64-bit process.\n"));
    }
    return 0;
}

要求

   
最低受支持的客户端 Windows Vista、Windows XP SP2 [仅限桌面应用]
最低受支持的服务器 Windows Server 2008、Windows Server 2003 SP1 [仅限桌面应用]
目标平台 Windows
标头 winuser.h (包括 Windows.h)
Library User32.lib
DLL User32.dll

另请参阅

GetNativeSystemInfo

IsWow64Process

WOW64