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

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

22.03.2012

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):