Получение версии Windows
В библиотеке требуется знать, под какой версией Windows (Win7, Vista etc) запущено приложение. Подскажите, как получить данную информацию от системы?
В библиотеке требуется знать, под какой версией Windows (Win7, Vista etc) запущено приложение. Подскажите, как получить данную информацию от системы?
У windows API есть такая функция GetVersionEx, которая вытаскивает исчерпывающую информацию о версии операционной системы...
PEB.NtMajorVersion, NtMinorVersion, NtBuildNumber или в US. Лучше из US, так как данный блок version-independent:
WARNING: This structure must have exactly the same layout for 32- and 64-bit systems. The layout of this structure cannot change and new fields can only be added at the end of the structure (unless a gap can be exploited). Deprecated fields cannot be deleted. Platform specific fields are included on all systems.
Layout exactness is required for Wow64 support of 32-bit applications on Win64 systems.
The layout itself cannot change since this structure has been exported in ntddk, ntifs.h, and nthal.h for some time.
Непосредственно структура:
NT_PRODUCT_TYPE NtProductType;
BOOLEAN ProductTypeIsValid;
//
// The NT Version.
//
// N. B. Note that each process sees a version from its PEB, but if the
// process is running with an altered view of the system version,
// the following two fields are used to correctly identify the
// version
//
ULONG NtMajorVersion;
ULONG NtMinorVersion;
Смещение поля NtMajorVersion: 0x7FFE026C
Информацию о версии ОС можно также найти и в реестре. Искать в
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions