Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
>
How can a 32-bit program detect that it…

How can a 32-bit program detect that it is launched in a 64-bit Windows?

Mar 22 2012
Author:

64-bit operating systems of the Windows family can execute 32-bit programs with the help of the WoW64 (Windows on Windows 64) subsystem that emulates the 32-bit environment due to an additional layer between a 32-bit application and 64-bit Windows API.

A 32-bit program can find out if it is launched in WoW64 with the help of the IsWow64Process function. The program can get additional information about the processor through the GetNativeSystemInfo function.

Keep in mind that the IsWow64Process function is included only in 64-bit Windows versions. You can use the GetProcAddress and GetModuleHandle functions to know if the IsWow64Process function is present in the system and to access it. This is an example demonstrating a correct use of the IsWow64Process function (download the project):

#include "stdafx.h"

bool IsWow64()
{
  BOOL bIsWow64 = FALSE;

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

  LPFN_ISWOW64PROCESS fnIsWow64Process;

  HMODULE module = GetModuleHandle(_T("kernel32"));
  const char funcName[] = "IsWow64Process";
  fnIsWow64Process = (LPFN_ISWOW64PROCESS)
    GetProcAddress(module, funcName);

  if(NULL != fnIsWow64Process)
  {
    if (!fnIsWow64Process(GetCurrentProcess(),
                          &bIsWow64))
      throw std::exception("Unknown error");
  }
  return bIsWow64 != FALSE;
}

void main()
{
  if (IsWow64())
    printf("The process is running under WOW64.\n");
  else
    printf("The process is not running under WOW64.\n");

  printf("\nPress Enter to continue...");
  getchar();
}

References

Popular related articles


Comments (0)

Next comments next comments
close comment form