Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How can I check the windows version ?

Posted on 2011-02-28
5
Medium Priority
?
471 Views
Last Modified: 2013-11-20
Hello,
I tried this code that I found on the web without luck.
I thing it is not complete.
I would like to get the current system in str_system.
This is only for Windows NT no later versions....how do I have to check for XP, Vista or 7?
Please help. 500 points with a solution.
...still lerarning MFC....thanks.

Best regards,
Thomas

CString str_system;
OSVERSIONINFO osver;
osver.dwOSVersionInfoSize = sizeof(osver);
if (GetVersionEx(&osver))
{
   if (osver.dwPlatformId == VER_PLATFORM_WIN32s)
   {
     str_system="Win32 ";
   }

   else if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
   {

    if (osver.dwMinorVersion == 0 && (strchr(osver.szCSDVersion,'B') == NULL)&& (strchr(osver.szCSDVersion,'C') == NULL))str_system="Windows 95 ";
    if (osver.dwMinorVersion == 10 && (strchr(osver.szCSDVersion,'A')   == NULL))str_system="Windows 98 ";
    if (osver.dwMinorVersion == 90)str_system="Windows Millenium Edition ";
    if (osver.dwPlatformId == VER_PLATFORM_WIN32_NT)str_system="Windows NT ";

   }

}

Open in new window

0
Comment
Question by:tsp2002
  • 3
5 Comments
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 34996724
0
 
LVL 11

Accepted Solution

by:
Deepu Abraham earned 2000 total points
ID: 34996975
Here is a snippet
void GetWindowsOS()
{

     OSVERSIONINFOEX       versionInfo;
     memset( &versionInfo, 0, sizeof versionInfo );
     versionInfo.dwOSVersionInfoSize = sizeof versionInfo;
     GetVersionEx( &versionInfo );

     switch (versionInfo.dwPlatformId)
     {
        case VER_PLATFORM_WIN32_WINDOWS:
           if (versionInfo.dwMajorVersion == 4 && versionInfo.dwMinorVersion == 90)
			AfxMessageBox(L"WINDOWS ME");
           if (versionInfo.dwMajorVersion == 4 && versionInfo.dwMinorVersion == 10)
                        AfxMessageBox(L"WINDOWS 98");
           if (versionInfo.dwMajorVersion == 4 && versionInfo.dwMinorVersion == 0)
                        AfxMessageBox(L"WINDOWS 95");
           break;

        case VER_PLATFORM_WIN32_NT:
           if ( versionInfo.dwMajorVersion == 5 && versionInfo.dwMinorVersion == 1 )
                       AfxMessageBox(L"WINDOWS XP");
           else if ( versionInfo.dwMajorVersion == 5 && versionInfo.dwMinorVersion == 0 )
                       AfxMessageBox(L"WINDOWS 2000");
           else if ( versionInfo.dwMajorVersion == 6 && versionInfo.dwMinorVersion == 0 )
           {
		   if( versionInfo.wProductType == VER_NT_WORKSTATION)
				AfxMessageBox(L"WINDOWS VISTA");
                   else 
				AfxMessageBox(L"WINDOWS 2K8 SERVER");
      	   }
           else if ( versionInfo.dwMajorVersion == 6 && versionInfo.dwMinorVersion == 1 )
	   {
		   if( versionInfo.wProductType == VER_NT_WORKSTATION)
			AfxMessageBox(L"WINDOWS 7");
                   else 
			AfxMessageBox(L"WINDOWS 2K8 SERVER");
           }

           break;
       }//Switch ends here 
}

Open in new window

0
 
LVL 11

Expert Comment

by:Deepu Abraham
ID: 34997034
0
 
LVL 11

Expert Comment

by:Deepu Abraham
ID: 34997049

http://msdn.microsoft.com/en-us/library/ms724832%28v=vs.85%29.aspx

Operating system      Version number
Windows 7                              6.1
Windows Server 2008 R2      6.1
Windows Server 2008        6.0
Windows Vista                      6.0
Windows Server 2003 R2      5.2
Windows Server 2003              5.2
Windows XP 64-Bit Edition      5.2
Windows XP                      5.1
Windows 2000                      5.0
0
 

Author Closing Comment

by:tsp2002
ID: 34997311
Thank you for your help,
best regards, Thomas
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question