VC++获取操作系统版本(摘自MSDN)
来源:互联网 发布:好的游戏优化软件 编辑:程序博客网 时间:2024/05/21 11:16
#include <windows.h>
#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;
}
- VC++获取操作系统版本(摘自MSDN)
- VC++获取操作系统版本(摘自MSDN)
- 获取操作系统版本(转MSDN)
- VC获取操作系统版本信息
- MSDN例子获取操作系统版本信息Getting the System Version
- VC获取操作系统版本和名称
- VC++ 获取操作系统的版本GetVersionEx函数
- 获取操作系统版本字符串(转自MSDN) 附判断操作系统的代码
- 获取操作系统版本
- 如何获取操作系统版本
- ruby获取操作系统版本
- 获取Windows操作系统版本
- RtlGetVersion获取操作系统版本
- with as (摘自msdn)
- 获取浏览器版本,获取操作系统
- (VC,MFC) 检测操作系统版本
- VC 判断 Windows 操作系统版本
- VC获取程序版本
- 编程规范之内存管理部分
- java发送邮件程序
- TCP/IP结构详述
- RDLC 静态加载图像,运行前加载图像
- 查看网络连接
- VC++获取操作系统版本(摘自MSDN)
- hibernate一个完整的应用(2)
- Linux下字符设备驱动程序的结构
- 用XenoCode 2006 加密dll (.NET混淆 )
- sql2000数据库快捷键大全
- VI使用总结
- 我大学时候做的《详解petshop4.0教程》,asp.net初学者可以看一看。
- myeclipse安装问题
- vim命令大全