4 Ocak 2015 Pazar

IsWow64 Function

#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <stdlib.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 )
{

SYSTEM_INFO sys;
GetSystemInfo(&sys);
DWORD sysar=sys.wProcessorArchitecture;
#if defined _WIN64
        if(IsWow64())
        _tprintf(TEXT("The process is running under WOW64.\n")); //process 64 and PC 32 --->BOYLE BIR IHTIMAL YOK(CALISMAZ)
        else
{
        _tprintf(TEXT("64 bit process under 64 bit PC \n")); //process 64 and PC 64
system("start C:\\Example64Bit"); //64 bit programı çalıştır
}
#elif defined _WIN32
    if(IsWow64())
{
            _tprintf(TEXT("32 bit process under 64 bit PC.\n")); //program 32, win64
   system("start C:\\Example64Bit");//64 bit programı çalıştır
}
else
{
_tprintf(TEXT("32 bit process under 32 bit PC \n")); //program 32, win32
    system("start C:\\32BitExample"); //32 bit programı çalıştır
}
#endif
    return 0;
}

Hiç yorum yok:

Yorum Gönder