Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I check the windows version ?

Posted on 2011-02-28
5
Medium Priority
?
469 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 44

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

715 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