본문 바로가기

개발자이야기/VC++

VC++ 간단한 윈도우 구분 방법

반응형
CString getWindowType(){
OSVERSIONINFOEX osvi;
BOOL bOsVersionInfoEx;

ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
{
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) ) 
return L"WinXP";
}

switch (osvi.dwPlatformId)
{
case VER_PLATFORM_WIN32_NT:
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 1 )//printf("Microsoft Windows 7 / Vista ");
return L"Win7/VISTA";
else if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )//printf ("Microsoft Windows Server 2003, ");
return L"WinServer2003";
else if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )//printf ("Microsoft Windows XP ");
return L"WinXP";
else if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )//printf ("Microsoft Windows 2000 ");
return L"Win2000";
else if ( osvi.dwMajorVersion <= 4 )//printf("Microsoft Windows NT ");
return L"WinNT";
break;
case VER_PLATFORM_WIN32_WINDOWS:
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)//printf ("Microsoft Windows 95 ");
return L"Win95";
else if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)//printf ("Microsoft Windows 98 ");
return L"Win98";
else if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)//printf ("Microsoft Windows Millennium Edition\n");
return L"WinME";
break;
case VER_PLATFORM_WIN32s:
return L"Win32";
break;
}
}

반응형