실행 중인 OS가 64 비트인지 확인하기 위해서는 IsWow64Process 를 이용하면 된다. 지원하지 않는 OS 도 있으니 GetProcAddress 를 이용해야한다. 64 비트 프로그램의 경우에는 그냥 TRUE 를 return 하면 된다.

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

LPFN_ISWOW64PROCESS fnIsWow64Process;

BOOL IsWow64()
{
#ifdef _WIN64
    return TRUE;
#else
    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;
#endif
}

참고 : https://msdn.microsoft.com/ko-kr/library/windows/desktop/ms684139(v=vs.85).aspx

728x90

+ Recent posts