示例#1
0
// detect if the OS we are running on is 64 or 32bit
// we only care when building on Intel for 32bit
QString SubsurfaceSysInfo::osArch()
{
	QString res = "";
#if defined(Q_PROCESSOR_X86_32)
#if defined(Q_OS_UNIX)
	struct utsname u;
	if (uname(&u) != -1) {
		res = u.machine;
	}
#elif defined(Q_OS_WIN)

	/* this code is from
	 * http://mark.koli.ch/reliably-checking-os-bitness-32-or-64-bit-on-windows-with-a-tiny-c-app
	 * there is no license given, but 5 lines of code should be fine to reuse unless explicitly forbidden */
	typedef BOOL (WINAPI *IW64PFP)(HANDLE, BOOL *);
	BOOL os64 = FALSE;
	IW64PFP IW64P = (IW64PFP)GetProcAddress(
				GetModuleHandle((LPCSTR)"kernel32"), "IsWow64Process");

	if(IW64P != NULL){
		IW64P(GetCurrentProcess(), &os64);
	}
	res = os64 ? "x86_64" : "i386";
#endif
#endif
	return res;
}
示例#2
0
QVariant Windows::getOsArchitecture(){
    BOOL res = FALSE;
    // When this application is compiled as a 32-bit app,
    // and run on a native 64-bit system, Windows will run
    // this application under WOW64.  WOW64 is the Windows-
    // on-Windows subsystem that lets native 32-bit applications
    // run in 64-bit land.  This calls the kernel32.dll
    // API to see if this process is running under WOW64.
    // If it is running under WOW64, then that clearly means
    // this 32-bit application is running on a 64-bit OS,
    // and IsWow64Process will return true.
    IW64PFP IW64P = (IW64PFP)GetProcAddress(GetModuleHandle (L"kernel32"), "IsWow64Process");

    if(IW64P != NULL){
      IW64P(GetCurrentProcess(), &res);
    }
    if(res){
        return "x86_64";
    }
    return "i386";
}