在开发过程中中,把开发过程中比较好的内容片段备份一次,下边内容段是关于C++获得当前windows系统的版本号的内容,应该能对码农们也有好处。#include InitWindowsVersion.h无WIN_VER_DETAIL GetWindowsVersion()...
在开发过程中中,把开发过程中比较好的内容片段备份一次,下边内容段是关于C++获得当前windows系统的版本号的内容,应该能对码农们也有好处。
#include "InitWindowsVersion.h"
无
WIN_VER_DETAIL GetWindowsVersion()
{
UNICODE_STRING ustrFuncName = { 0 };
RTL_OSVERSIONINFOEXW osverinfo = { sizeof(osverinfo) };
PFN_RtlGetVersion pfnRtlGetVersion = NULL;
if (WinVersion)
return WinVersion;
RtlInitUnicodeString(&ustrFuncName, L"RtlGetVersion");
if (pfnRtlGetVersion)
{
pfnRtlGetVersion((PRTL_OSVERSIONINFOW)&osverinfo);
}
else
{
PsGetVersion(&osverinfo.dwMajorVersion, &osverinfo.dwMinorVersion, &osverinfo.dwBuildNumber, NULL);
}
if (osverinfo.dwMajorVersion == 5 && osverinfo.dwMinorVersion == 0)
{
WinVersion = WINDOWS_VERSION_2K;
}
else if (osverinfo.dwMajorVersion == 5 && osverinfo.dwMinorVersion == 1)
{
WinVersion = WINDOWS_VERSION_XP;
}
else if (osverinfo.dwMajorVersion == 5 && osverinfo.dwMinorVersion == 2)
{
if (osverinfo.wServicePackMajor==0)
{
WinVersion = WINDOWS_VERSION_2K3;
}
else
{
WinVersion = WINDOWS_VERSION_2K3_SP1_SP2;
}
}
else if (osverinfo.dwMajorVersion == 6 && osverinfo.dwMinorVersion == 0)
{
WinVersion = WINDOWS_VERSION_2K3_SP1_SP2;
}
else if (osverinfo.dwMajorVersion == 6 && osverinfo.dwMinorVersion == 1)
{
WinVersion = WINDOWS_VERSION_7;
}
return WinVersion;
}
InitWindowsVersion.h
#ifndef _SYSTEM_H
#define _SYSTEM_H
#include "ntifs.h"
typedef enum WIN_VER_DETAIL {
WINDOWS_VERSION_2K,
WINDOWS_VERSION_XP,
WINDOWS_VERSION_2K3,
WINDOWS_VERSION_2K3_SP1_SP2,
WINDOWS_VERSION_VISTA_2008,
WINDOWS_VERSION_7
} WIN_VER_DETAIL;
WIN_VER_DETAIL WinVersion;
WIN_VER_DETAIL GetWindowsVersion();
#endif
沃梦达教程
本文标题为:C++获得当前windows系统的版本号的代码
基础教程推荐
猜你喜欢
- 如何C++使用模板特化功能 2023-03-05
- 详解c# Emit技术 2023-03-25
- C/C++编程中const的使用详解 2023-03-26
- C语言基础全局变量与局部变量教程详解 2022-12-31
- 一文带你了解C++中的字符替换方法 2023-07-20
- C语言 structural body结构体详解用法 2022-12-06
- C++详细实现完整图书管理功能 2023-04-04
- C++中的atoi 函数简介 2023-01-05
- C利用语言实现数据结构之队列 2022-11-22
- C++使用easyX库实现三星环绕效果流程详解 2023-06-26