Search This Blog

Friday, April 12, 2013

How To Find 64-bit Operating System?

During installation of a software we copy the files based on 32-bit or 64-bit operation system.

For example,
In 64-bit OS,  we install 32-bit applications in to "C:\Program Files (x86)" folder and 64-bit into "C:\Program Files" folder by default.

Like that we load different DLLs(based on compilation method as 32 or 64 bit) based on the OS architecture to improve the speed of the process.

The following function code helps you to find whether OS installed is 32 or 64-bit Operating System.



BOOL Is64BitOS()
{
    typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
    PGNSI pGNSI;
    SYSTEM_INFO sysinfo;
    ZeroMemory(&sysinfo, sizeof(SYSTEM_INFO));
    pGNSI = (PGNSI) GetProcAddress(
      GetModuleHandle(TEXT("kernel32.dll")), 
      "GetNativeSystemInfo");

    if(NULL != pGNSI)
    {
      pGNSI(&sysinfo);
    //GetNativeSystemInfo(&sysinfo);
    if(PROCESSOR_ARCHITECTURE_AMD64==sysinfo.wProcessorArchitecture)
        return TRUE;
    else
        return FALSE;
    }
    else
        return FALSE;
}

No comments:

Post a Comment