Share via


IsWow64Message 函式 (winuser.h)

判斷從目前線程佇列讀取的最後一則訊息是否源自 WOW64 進程。

Syntax

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)
程式庫 User32.lib
Dll User32.dll

另請參閱

GetNativeSystemInfo

IsWow64Process

WOW64