#include <windows.h>
#include <iostream>
bool Is64BitWindows() {
#if defined(_WIN64)
// If the process is compiled for 64-bit, it's running on a 64-bit OS.
return true;
#elif defined(_WIN32)
// If the process is compiled for 32-bit, check if it's running under WOW64.
// WoW64 is a subsystem of the Windows operating system capable of running -
// - 32-bit applications on 64-bit Windows.
BOOL isWow64 = FALSE;
if (IsWow64Process(GetCurrentProcess(), &isWow64)) {
return isWow64;
}
else {
// If the function fails, assume 32-bit OS.
return false;
}
#else
// Unknown architecture.
return false;
#endif
}
int main() {
if (Is64BitWindows()) {
std::cout << "The system is 64-bit." << std::endl;
}
else {
std::cout << "The system is 32-bit." << std::endl;
}
}
/*
run
The system is 64-bit.
*/