[C.C++] c 读取系统语言,怎么用c语言获取当前操作系统的类型

45 0
Honkers 昨天 17:27 | 显示全部楼层 |阅读模式

如何用c语言获取当前操作系统的类型?

如何获取当前操作系统的类型,比如xp,win7,win8???

c语言

分享到:

------解决方案--------------------

OSVERSIONINFOEX version_info = { sizeof version_info };

GetVersionEx(reinterpret_cast(&version_info));

version_number_.major = version_info.dwMajorVersion;

version_number_.minor = version_info.dwMinorVersion;

version_number_.build = version_info.dwBuildNumber;

if ((version_number_.major == 5) && (version_number_.minor > 0)) {

// Treat XP Pro x64, Home Server, and Server 2003 R2 as Server 2003.

version_ = (version_number_.minor == 1) ? VERSION_XP : VERSION_SERVER_2003;

} else if (version_number_.major == 6) {

switch (version_number_.minor) {

case 0:

// Treat Windows Server 2008 the same as Windows Vista.

version_ = VERSION_VISTA;

break;

case 1:

// Treat Windows Server 2008 R2 the same as Windows 7.

version_ = VERSION_WIN7;

break;

case 2:

// Treat Windows Server 2012 the same as Windows 8.

version_ = VERSION_WIN8;

break;

default:

DCHECK_EQ(version_number_.minor, 3);

version_ = VERSION_WIN8_1;

break;

}

} else if (version_number_.major > 6) {

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2025 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行