Solved

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

Posted on 2003-11-08
2
580 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now