Getting the user's OS

This is a discussion on Getting the user's OS within the Windows Programming forums, part of the Platform Specific Boards category; I'm trying to detect a user's OS but I'm not getting the correct results. Is there something I'm missing? Code: ...

  1. #1
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283

    Getting the user's OS

    I'm trying to detect a user's OS but I'm not getting the correct results. Is there something I'm missing?

    Code:
    OSVERSIONINFO osInfo;
    
    	// Get Windows version. 
    	ZeroMemory(&osInfo, sizeof(osInfo));
    	GetVersionEx(&osInfo);
    
    	if(osInfo.dwPlatformId == 1) 
    	{
    		if((osInfo.dwMajorVersion == 4) && (osInfo.dwMinorVersion == 0))
    			objSystemInfo.OperatingSystem.Windows95 = true;
    		else if((osInfo.dwMajorVersion == 4) && (osInfo.dwMinorVersion == 10))
    			objSystemInfo.OperatingSystem.Windows98 = true;
    		else if((osInfo.dwMajorVersion == 4) && (osInfo.dwMinorVersion == 90))
    			objSystemInfo.OperatingSystem.WindowsME = true; 
    	}
    
    	// Win NT
    	else if(osInfo.dwPlatformId == 2)
    	{
    		if((osInfo.dwMajorVersion == 4) && (osInfo.dwMinorVersion == 0))
    			objSystemInfo.OperatingSystem.WindowsNT4 = true;
    		else if((osInfo.dwMajorVersion == 5) && (osInfo.dwMinorVersion == 0))
    			objSystemInfo.OperatingSystem.Windows2000 = true;
    		else if((osInfo.dwMajorVersion == 5) && (osInfo.dwMinorVersion == 1))
    			objSystemInfo.OperatingSystem.WindowsXP = true;
    		else if((osInfo.dwMajorVersion == 5) && (osInfo.dwMinorVersion == 2))
    		{
    			if(GetSystemMetrics(89))	 
    				objSystemInfo.OperatingSystem.WindowsServer2003R2 = true;
    		}
    		else if((osInfo.dwMajorVersion == 6) && (osInfo.dwMinorVersion == 0))
    			objSystemInfo.OperatingSystem.WindowsVista = true; 
    		else if((osInfo.dwMajorVersion == 6) && (osInfo.dwMinorVersion == 1))
    			objSystemInfo.OperatingSystem.Windows7 = true; 
    	}

  2. #2
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283
    For extra info, I'm getting '0' for osInfo.dwPlatformId.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    You mean, like doing something sane like RTFM perhaps?

    > Before calling the GetVersionEx function, set the dwOSVersionInfoSize member of the structure as appropriate to indicate which data structure is being passed to this function.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283
    Adding you to my be aware / PMS developer list.

    And there is no such member for the structure I'm using. Read on and get some pills.

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by dxfoo View Post
    Adding you to my be aware / PMS developer list.

    And there is no such member for the structure I'm using. Read on and get some pills.
    Indeed, RTFM.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  6. #6
    Software engineer
    Join Date
    Aug 2005
    Location
    Oregon
    Posts
    283
    Ah, yes... my mistake. But seriously, work on the attitude. Some of us come from a professional background and looking at your post just sounds really amateur and rude.

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,851
    Professional?
    Ha - don't make me laugh - what sort of pro posts on a board without reading the manual first?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  8. #8
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Adding you to my be aware / PMS developer list.
    Just so you know Salem is probably one of the most knowledgeable and helpful programmers on this board. His attitude or more appropriately the shared attitude of the members of the board comes from answering ten million questions that could have been answered with a simple Google search or a quick read on MSDN. No one in the world has the Win32 API memorized so I guess what we are saying here is have the help docs readily available while programming in Win32. Most companies even give you an MSDN subscription and/or get MSDN on CD's/DVD's every quarter that you can then install on your machine. If there is one thing we have readily available today it is information.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 04:25 AM
  2. Function validation.
    By Fhl in forum C Programming
    Replies: 10
    Last Post: 02-22-2006, 08:18 AM
  3. Windows ntfs perms
    By wp_x in forum Tech Board
    Replies: 3
    Last Post: 03-04-2003, 06:38 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21