How to Determine OS

I want a win32 console program to determine if its running in WIN9x or WINNT.
theberAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

theberAuthor Commented:
Edited text of question.
0
jkrCommented:
Use

OSVERSIONINFO osviVerInfo;
osviVerInfo.dwOSVersionInfoSize = sizeof ( OSVERSIONINFO);

GetVersionEx ( &osviVerInfo);

switch ( osviVerInfo.dwPlatformId)
{
 case VER_PLATFORM_WIN32_WINDOWS: // Win32 on Win95
      break;
 case VER_PLATFORM_WIN32_NT: // Win32 on WinNT
      break;
 case VER_PLATFORM_WIN32_WIN32sS: // Win32s on Win 3.x
      break;
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
theberAuthor Commented:
Edited text of question.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

jkrCommented:
Or (a little bit more convenient ;-)

BOOL    IsNT    ()
{
    OSVERSIONINFO       osviVerInfo;

    osviVerInfo.dwOSVersionInfoSize =   sizeof  (   OSVERSIONINFO);

    GetVersionEx    (   &osviVerInfo);

    return  (   VER_PLATFORM_WIN32_NT   ==  osviVerInfo.dwPlatformId);
    return  (   TRUE);
}
0
jkrCommented:
Ooops, sorry, this should of course be

BOOL    IsNT    ()
{
    OSVERSIONINFO       osviVerInfo;

    osviVerInfo.dwOSVersionInfoSize =   sizeof  (   OSVERSIONINFO);

    GetVersionEx    (   &osviVerInfo);

    return  (   VER_PLATFORM_WIN32_NT   ==  osviVerInfo.dwPlatformId);
 }
0
jkrCommented:
If you want this to be a complete program, use

#include <windows.h>
#include <stdio.h>

BOOL    IsNT    ()
{
    OSVERSIONINFO       osviVerInfo;

    osviVerInfo.dwOSVersionInfoSize =   sizeof  (   OSVERSIONINFO);

    GetVersionEx    (   &osviVerInfo);

    return  (   VER_PLATFORM_WIN32_NT   ==  osviVerInfo.dwPlatformId);
}

void main ( void)
{
 if ( IsNT())
     printf ( "\nThis is Windows NT\n");
 else
     printf ( "\nThis is Windows 9x\n");
}
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.