Loading...

Thursday, 9 August 2012

How to check OS version (C++)

#include<stdio.h>
#include<string.h>
#include<windows.h>

int IsWin7OrLater() {
        DWORD version = GetVersion();
        DWORD major = (DWORD) (LOBYTE(LOWORD(version)));
        DWORD minor = (DWORD) (HIBYTE(LOWORD(version)));

        if((major > 6) || ((major == 6) && (minor >= 1))){
            return 1;
        }
        else return 0;

    }
int main (){

    if(IsWin7OrLater()){
        printf("Windows 7");
    }
    else
       printf("Windows XP");

    return 0;
}

No comments:

Post a Comment