如题
GetVersionEX()可以吗
给出实例,谢谢!
GetVersionEX()可以吗
给出实例,谢谢!
解决方案 »
- MS Visual C++6.0正版软件。一名用户使用权限版本,售价可以接受。请进。
- 专科生的独白 --恨自己,悔当初!
- 语音识别软件编程问题
- 请教高手
- YUV2LPR.exe 中的 0x75399617 处未处理的异常: Microsoft C++ 异常: 内存位置 0x2705de68 处的 cv::Exce
- 送分問題
- First-chance exception in ...算是错误还是正常?
- 有很大一张表(如有几千万条记录),根据条件在其中查讯相关记录,查询出的记录需要分页,此时是将查询出的记录全部保存在服务器内存中,每次根据分页的页数返回一些数据,还是每次查询数据库,根据页数返回记录?
- 请问各位大侠:如何实现自画菜单?
- 非unicode MFC程序使用unicode dll的问题
- 请教bmp的一个显示问题
- 诚邀加盟
#include <stdio.h>BOOL DisplaySystemVersion()
{
OSVERSIONINFOEX osvi;
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;
}
Major version number of the operating system. This member can be one of the following values. Operating System Meaning
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 Server 2003 family 5 [dwMinorVersion ]
Minor version number of the operating system. This member can be one of the following values. Operating System Meaning
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 Server 2003 family 2