티스토리 뷰

개발/윈도우

OS Version Util

-=HaeJuK=- 2024. 4. 22. 13:17
728x90
#include <iostream>
#include <windows.h>

typedef LONG NTSTATUS, * PNTSTATUS;
#define STATUS_SUCCESS (0x00000000)
extern "C" NTSTATUS NTAPI RtlGetVersion( PRTL_OSVERSIONINFOW lpVersionInformation );

#ifndef NT_SUCCESS
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
#endif


class cWinVersion
{
    DECLARE_NO_SELF_CLASS( nxcWinVersion );

    static bool IsSystem64Bit() {
        SYSTEM_INFO si;
        GetNativeSystemInfo( &si );

        // PROCESSOR_ARCHITECTURE_AMD64 indicates 64-bit, PROCESSOR_ARCHITECTURE_INTEL indicates 32-bit
        return si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64;
    }

    static bool IsWow64Mode() {
        BOOL bIsWow64 = FALSE;
        if( IsWow64Process( GetCurrentProcess(), &bIsWow64 ) ) {
            if( bIsWow64 ) {
                std::cout << "Architecture: 64-bit system\n";
            }
            else {
                std::cout << "Architecture: 32-bit system\n";
            }
        }
        else {
            std::cout << "Failed to determine architecture.\n";
        }
        return bIsWow64;
    }
    static bool IsWin11() {
        RTL_OSVERSIONINFOW rovi = { 0 };
        rovi.dwOSVersionInfoSize = sizeof( rovi );
        NTSTATUS status = RtlGetVersion( &rovi );
        return NT_SUCCESS( status ) && rovi.dwMajorVersion == 10 && rovi.dwBuildNumber >= 22000;
    }

    static  bool IsWin10() {
        RTL_OSVERSIONINFOW rovi = { 0 };
        rovi.dwOSVersionInfoSize = sizeof( rovi );
        NTSTATUS status = RtlGetVersion( &rovi );
        return NT_SUCCESS( status ) && rovi.dwMajorVersion == 10 && rovi.dwBuildNumber < 22000;
    }

    static  bool IsWin8_1() {
        RTL_OSVERSIONINFOW rovi = { 0 };
        rovi.dwOSVersionInfoSize = sizeof( rovi );
        NTSTATUS status = RtlGetVersion( &rovi );
        return NT_SUCCESS( status ) && rovi.dwMajorVersion == 6 && rovi.dwMinorVersion == 3;
    }

    static  bool IsWin8() {
        RTL_OSVERSIONINFOW rovi = { 0 };
        rovi.dwOSVersionInfoSize = sizeof( rovi );
        NTSTATUS status = RtlGetVersion( &rovi );
        return NT_SUCCESS( status ) && rovi.dwMajorVersion == 6 && rovi.dwMinorVersion == 2;
    }

    static  bool IsWin7() {
        RTL_OSVERSIONINFOW rovi = { 0 };
        rovi.dwOSVersionInfoSize = sizeof( rovi );
        NTSTATUS status = RtlGetVersion( &rovi );
        return NT_SUCCESS( status ) && rovi.dwMajorVersion == 6 && rovi.dwMinorVersion == 1;
    }

    static bool IsWinVista() {
        RTL_OSVERSIONINFOW rovi = { 0 };
        rovi.dwOSVersionInfoSize = sizeof( rovi );
        NTSTATUS status = RtlGetVersion( &rovi );
        return NT_SUCCESS( status ) && rovi.dwMajorVersion == 6 && rovi.dwMinorVersion == 0;
    }

    static bool IsWinXp() {
        RTL_OSVERSIONINFOW rovi = { 0 };
        rovi.dwOSVersionInfoSize = sizeof( rovi );
        NTSTATUS status = RtlGetVersion( &rovi );
        return NT_SUCCESS( status ) && rovi.dwMajorVersion == 5 && (rovi.dwMinorVersion == 1 || rovi.dwMinorVersion == 2);
    }
};
반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함
250x250