티스토리 뷰

Visual Studio 2012


운영체제의 Bit를 확인해보자(32Bit/64Bit).


1. 함수원형은 다음과 같다.


// ...
BOOL Is64BitWindows();
//...


2. 소스코드

클래스이름에 본인이 작업할 클래스명을 적으면 된다.

OS가 64비트면 TRUE, 32비트면 FALSE를 반환한다.


// ...
BOOL 클래스이름::Is64BitWindows()
{
#if defined(_WIN64)
	return TRUE;  // 64-bit programs run only on Win64
#elif defined(_WIN32)
	// 32-bit programs run on both 32-bit and 64-bit Windows
	// so must sniff
	BOOL f64 = FALSE;
	return IsWow64Process(GetCurrentProcess(), &f64) && f64;
#else
	return FALSE; // Win64 does not support Win16
#endif
}
}
//...


3. 테스트 하기

자기 자신을 핑검색 한 후에 검색 내용을 메시지박스로 표현한다.

코드 실행은 다음과 같이 진행한다.


// ...
	if(Is64BitWindows())
		AfxMessageBox("64Bit");
	else
		AfxMessageBox("32Bit");
//...


댓글