Click here to Skip to main content
Click here to Skip to main content

Check Windows 7 version in Visual C++

, 29 Jul 2011
Rate this:
Please Sign up or sign in to vote.
How to check the Windows 7 version in VC++.

For testing that the Windows OS running is Windows 7, use this code:

bool IsWindows7()
{
    OSVERSIONINFOEX osvi;
    bool bOsVersionInfoEx=false;
    DWORD dwType=0UL;
    bool bWin7=false;
    ZeroMemory(&osvi, sizeof(SYSTEM_INFO));
    ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
    osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
    if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
        return -1;
    if(osvi.dwMajorVersion==6)
    {
        if(osvi.dwMinorVersion==1)
        {
            if(osvi.wProductType==VER_NT_WORKSTATION)
            {
                bWin7=true;
            }
        }
    }
    return bWin7;
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author


Comments and Discussions

 
GeneralReason for my vote of 1 1 Pinmemberkoteswara Rao 20112-Aug-11 21:07 
GeneralReason for my vote of 1 Is this code snippet a bad copy from... PinmemberAxel Zur1-Aug-11 21:41 
Question[My vote of 1] Is this code snippet a bad copy from somewhere? PinmemberAxel Zur1-Aug-11 21:46 
QuestionBetter way Pinmemberwaleri29-Jul-11 21:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 29 Jul 2011
Article Copyright 2011 by Sayyed Mostafa Hashemi
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid