Solved

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

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

Industry Leaders: 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

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.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

756 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