Series

Detect Windows Architecture [C++] std::getenv

More Code 2018. 6. 25. 04:17


// C++

// VC : suppress error messages about obsolete & deprecated functions
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdlib>

using namespace std;

int main(int argc, char *argv[])
{
if (const char *myArchitecture = getenv("PROCESSOR_ARCHITECTURE"))
cout << "PROCESSOR_ARCHITECTURE : " << myArchitecture << endl;

if (const char *myArchiteW6432 = getenv("PROCESSOR_ARCHITEW6432"))
cout << "PROCESSOR_ARCHITEW6432 : " << myArchiteW6432 << endl;

return EXIT_SUCCESS;
}

/* Output
PROCESSOR_ARCHITECTURE : x86
PROCESSOR_ARCHITEW6432 : AMD64
*/