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

Check Windows 7 version in Visual C++

By , 29 Jul 2011
Rate this:
Please Sign up or sign in to vote.

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

bool IsWindows7()
    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;
    return bWin7;


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

About the Author

Sayyed Mostafa Hashemi
Software Developer (Senior)
Iran (Islamic Republic Of) Iran (Islamic Republic Of)
I am Mostafa Hashemi.I was born in Tehran. I graduated from IUMS university in 2002 (1381). Although my university field different from programming, but I like it. Since I acquainted with computer, I have been interested in Visual C++. I have been beginning to program in Visual C++ in 2003.

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
Web01 | 2.8.140415.2 | Last Updated 29 Jul 2011
Article Copyright 2011 by Sayyed Mostafa Hashemi
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid