Determining 64-bit OS

I have an app which reads from the registry to look for some registry keys written by a 32-bit app. When run on 64bit windows, the registry entries are under Wow6432Node. How do I determine if the user is running 64-bit windows.

Thanks

Dan



Answer this question

Determining 64-bit OS

  • Deb Magsam

    You can do an IsWow64Process api call to see.

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

    BOOL IsWow64()
    {

    BOOL bIsWow64 = FALSE; // assume 32 bit

    // can't call IsWow64Process on x32, so first look up the entry point in kernel32
    LPFN_ISWOW64PROCESS fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle ("kernel32"),"IsWow64Process");
    // if we have an entry point for IsWow64Process, we can call it
    if (NULL != fnIsWow64Process)
    {
    if (!fnIsWow64Process(GetCurrentProcess(),&bIsWow64))
    {
    // handle error
    }
    }
    return bIsWow64;
    }


  • globemast

    Check the "PROCESSOR_ARCHITECTURE" environment variable. If it's not "x86" it's 64 bit.

    I think the valid values are "AMD64", "x64" and "IA64" (obviously not relevant to Vista)

  • Jonas Beckeman

    If you install a 32bit OS on a 64bit processor, the value will be "x86"

  • CorneVR

    Though couldn't you install the 32-bit OS on any of those

    Dan


  • raj.ramesh

    I'm not really sure, but I guess you could check to see if the 32-bit Program Files folder exists (c:\Program Files (x86)).

    Probably not the simplest way, but the only way I can think of without messing around on 64bit Vista for a while :)

    Andy



  • Determining 64-bit OS