请问如何检测本系统是2K还是XP?
解决方案 »
- 求救,HELP,如何通过一个ATL控件创建另一个ATL windowlESS控件,高分回报!
- 找不到pgort80.dll问题
- 成员函数存储在哪个区?
- 关于从资源读取BMP文件,显示到View里的问题,请帮忙看看
- 我,我今天满二十二了!各位师哥师姐进来畅谈以下你找工作经历!……一个迷失方向的准毕业生!
- 初学入门,请指教!
- 程序总是意外退出,有时候又正常!什么原因可以导致这样?(mfc,listview)
- 如何得到一个对话框除去菜单,状态栏等以后的大小??
- 各位高手,100分求Msagent如何Speak中文?
- MFC 为什么在线程中使用windows media player控件播放视频显示不出来
- 怎样编程实现在CEditView里添加一行
- 简单问题
LPOSVERSIONINFO lpVersionInfo // version information
);
Identifies the major version number of the operating system as follows. Operating System Value
Windows 95 4
Windows 98 4
Windows Me 4
Windows NT 3.51 3
Windows NT 4.0 4
Windows 2000 5
Windows XP 5
Windows .NET Server 5
dwMinorVersion
Identifies the minor version number of the operating system as follows. Operating System Value
Windows 95 0
Windows 98 10
Windows Me 90
Windows NT 3.51 51
Windows NT 4.0 0
Windows 2000 0
Windows XP 1
Windows .NET Server 1
BOOL bOsVersionInfoEx; // Try calling GetVersionEx using the OSVERSIONINFOEX structure.
//
// If that fails, try using the OSVERSIONINFO structure. ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
{
// If OSVERSIONINFOEX doesn't work, try OSVERSIONINFO. osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
return FALSE;
} switch (osvi.dwPlatformId)
{
case VER_PLATFORM_WIN32_NT: // Test for the product. if ( osvi.dwMajorVersion <= 4 )
printf("Microsoft Windows NT "); if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
printf ("Microsoft Windows 2000 "); if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
printf ("Microsoft Windows XP "); // Test for product type. if( bOsVersionInfoEx )
{
if ( osvi.wProductType == VER_NT_WORKSTATION )
{
if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
printf ( "Personal " );
else
printf ( "Professional " );
} else if ( osvi.wProductType == VER_NT_SERVER )
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
printf ( "DataCenter Server " );
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
printf ( "Advanced Server " );
else
printf ( "Server " );
}
}
else
{
HKEY hKey;
char szProductType[80];
DWORD dwBufLen; RegOpenKeyEx( HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
0, KEY_QUERY_VALUE, &hKey );
RegQueryValueEx( hKey, "ProductType", NULL, NULL,
(LPBYTE) szProductType, &dwBufLen);
RegCloseKey( hKey );
if ( lstrcmpi( "WINNT", szProductType) == 0 )
printf( "Professional " );
if ( lstrcmpi( "LANMANNT", szProductType) == 0 )
printf( "Server " );
if ( lstrcmpi( "SERVERNT", szProductType) == 0 )
printf( "Advanced Server " );
} // Display version, service pack (if any), and build number. if ( osvi.dwMajorVersion <= 4 )
{
printf ("version %d.%d %s (Build %d)\n",
osvi.dwMajorVersion,
osvi.dwMinorVersion,
osvi.szCSDVersion,
osvi.dwBuildNumber & 0xFFFF);
}
else
{
printf ("%s (Build %d)\n",
osvi.szCSDVersion,
osvi.dwBuildNumber & 0xFFFF);
}
break; case VER_PLATFORM_WIN32_WINDOWS: if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
{
printf ("Microsoft Windows 95 ");
if ( osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B' )
printf("OSR2 " );
} if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
{
printf ("Microsoft Windows 98 ");
if ( osvi.szCSDVersion[1] == 'A' )
printf("SE " );
} if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
{
printf ("Microsoft Windows Me ");
}
break; case VER_PLATFORM_WIN32s: printf ("Microsoft Win32s ");
break;
}
return TRUE;
printf("Microsoft Windows NT "); if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
printf ("Microsoft Windows 2000 "); if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
printf ("Microsoft Windows XP ");
{
OSVERSIONINFO osv;
osv.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
GetVersionEx( &osv );
CString osName;
switch( osv.dwPlatformId ) {
case 1:
{
switch( osv.dwMinorVersion )
case 0:
osName = "Windows 95";
break;
case 10:
osName = "Windows 98";
break;
case 90:
osName = "Windows Me";
break;
}
break;
case 2:
switch( osv.dwMajorVersion ) {
case 3:
osName = "Windows NT 3.51";
break;
case 4:
osName = "Windows NT 4.0";
break;
case 5:
{
switch(osv.dwMinorVersion)
{
case 0:
osName = "Windows 2000";
break;
case 1:
osName = "Windows XP";
break;
case 2:
osName = "Windows 2003 Server";
break;
}
}
break;
}
break;
default:
osName = "Unknow OS";
}
return osName;
}