Solved

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

Posted on 2003-11-08
2
584 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 50 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

Suggested Solutions

A short article about a problem I had getting the GPS LocationListener working.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

738 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