mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-20 05:29:37 +01:00
25 lines
722 B
C++
25 lines
722 B
C++
|
|
#include <Windows.h>
|
||
|
|
|
||
|
|
#include "WindowsVersions.h"
|
||
|
|
|
||
|
|
// Declared in wdm.h
|
||
|
|
typedef NTSYSAPI NTSTATUS (NTAPI *RtlGetVersionType)( PRTL_OSVERSIONINFOW );
|
||
|
|
|
||
|
|
DWORD GetWindowsBuild( DWORD* revision )
|
||
|
|
{
|
||
|
|
if( revision ) {
|
||
|
|
|
||
|
|
DWORD size = sizeof( *revision );
|
||
|
|
if( RegGetValueW( HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", L"UBR", RRF_RT_REG_DWORD, NULL, revision, &size ) != ERROR_SUCCESS ) {
|
||
|
|
|
||
|
|
*revision = 0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
RtlGetVersionType pRtlGetVersion = reinterpret_cast<RtlGetVersionType>(GetProcAddress( GetModuleHandleW( L"ntdll.dll" ), "RtlGetVersion" ));
|
||
|
|
|
||
|
|
RTL_OSVERSIONINFOW version;
|
||
|
|
pRtlGetVersion( &version );
|
||
|
|
return version.dwBuildNumber;
|
||
|
|
}
|