您好,登錄后才能下訂單哦!
在開發(fā)過程中中,把開發(fā)過程中比較好的內(nèi)容片段備份一次,下邊內(nèi)容段是關于C++獲得當前windows系統(tǒng)的版本號的內(nèi)容,應該能對碼農(nóng)們也有好處。
#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
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。