Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C++ Windows Program...   How to find out what version of Windows the user has?   ***EASY QUESTION***

Posted on 2003-11-08
2
Medium Priority
?
597 Views
Last Modified: 2013-11-13
For a project I am doing I need to know what version of Windows the person running the program has?   For example, is it Windows 95?  Windows NT?  Windows XP?  ect.....  

This is probly really easy, but i could not find the answer anywhere, so please enlighten me!

Thanks in advance!
0
Comment
Question by:Mazrim
[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
  • 2
2 Comments
 
LVL 19

Expert Comment

by:Dexstar
ID: 9708583
Mazrim:

> For a project I am doing I need to know what version of Windows the person
> running the program has?   For example, is it Windows 95?  Windows NT?  Windows
> XP?  ect.....

> This is probly really easy, but i could not find the answer anywhere, so please enlighten me!

Use the Win32 API function "GetVersionEx".  It will fill in a struct with all the info you need.  Here is how to use it:
     http://msdn.microsoft.com/library/en-us/sysinfo/base/getversionex.asp

Here is a wrapper class that I use:
      class CVersion : public OSVERSIONINFO
      {
      // Construction
      public:  
            CVersion()
            {
                  dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
                  _CTL_DEBUG_FAIL( ::GetVersionEx(this) );
            }
      };


Hope that helps,
Dex*
0
 
LVL 19

Accepted Solution

by:
Dexstar earned 200 total points
ID: 9708588
> Here is a wrapper class that I use:

Actually, you don't have my debugging library, so that won't help you.  Use this instead:

     class CWindowsVersion : public OSVERSIONINFO
     {
     // Construction
     public:  
          CWindowsVersion()
          {
               dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
               ::GetVersionEx( this );
          }
     };


Dex*
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Progress
Starting up a Project

636 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