Solved

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

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This is about my first experience with programming Arduino.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

810 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