I'm baffled by this... 
Author Message
 I'm baffled by this...

I have a function that checks if my app. is running on a WinNT platform. It
looks like this:

BOOL IsWinNT()
{
 OSVERSIONINFO verInfo;
 verInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
 if (!GetVersionEx(&verInfo))
  return FALSE;
 if (verInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
  return TRUE;
 return FALSE;

Quote:
}

This works correctly on my WinNT, Win2000 and WinXP systems. However, on one
of our customers systems running Win2000 Pro Service Pack 3 it fails
(returns FALSE)! If I change the code as follows it works (returns TRUE):

BOOL IsWinNT()
{
 OSVERSIONINFO verInfo;
 verInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
 if (GetVersionEx(&verInfo) > 0 && verInfo.dwPlatformId ==
VER_PLATFORM_WIN32_NT)
  return TRUE;
 return FALSE;

Quote:
}

Can anyone shed any light on why the first version doesn't work.

TIA

Mike



Tue, 13 Sep 2005 17:17:15 GMT  
 I'm baffled by this...
If GetVersionEx() fails, what does GetLastError() return?

I tried your code on my Windows 2000 SP3 machine and it returned TRUE.


Quote:
> I have a function that checks if my app. is running on a WinNT platform.
It
> looks like this:

> BOOL IsWinNT()
> {
>  OSVERSIONINFO verInfo;
>  verInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
>  if (!GetVersionEx(&verInfo))
>   return FALSE;
>  if (verInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
>   return TRUE;
>  return FALSE;
> }



Tue, 13 Sep 2005 19:07:33 GMT  
 I'm baffled by this...
I use something similar. But additionally I use the dwMajorVersion and
dwMinorVersion to determine the correct os.
Works fine.



Quote:
> I have a function that checks if my app. is running on a WinNT platform.
It
> looks like this:

> BOOL IsWinNT()
> {
>  OSVERSIONINFO verInfo;
>  verInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
>  if (!GetVersionEx(&verInfo))
>   return FALSE;
>  if (verInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
>   return TRUE;
>  return FALSE;
> }

> This works correctly on my WinNT, Win2000 and WinXP systems. However, on
one
> of our customers systems running Win2000 Pro Service Pack 3 it fails
> (returns FALSE)! If I change the code as follows it works (returns TRUE):

> BOOL IsWinNT()
> {
>  OSVERSIONINFO verInfo;
>  verInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
>  if (GetVersionEx(&verInfo) > 0 && verInfo.dwPlatformId ==
> VER_PLATFORM_WIN32_NT)
>   return TRUE;
>  return FALSE;
> }

> Can anyone shed any light on why the first version doesn't work.

> TIA

> Mike



Wed, 14 Sep 2005 15:05:26 GMT  
 I'm baffled by this...
But that's the baffling part - GerVersionEx() DOESN'T fail, it returns 1! My
two functions are almost identical except for the return code check from
GetVersionEx().

Mike



Quote:
> If GetVersionEx() fails, what does GetLastError() return?

> I tried your code on my Windows 2000 SP3 machine and it returned TRUE.



> > I have a function that checks if my app. is running on a WinNT platform.
> It
> > looks like this:

> > BOOL IsWinNT()
> > {
> >  OSVERSIONINFO verInfo;
> >  verInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
> >  if (!GetVersionEx(&verInfo))
> >   return FALSE;
> >  if (verInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
> >   return TRUE;
> >  return FALSE;
> > }



Fri, 16 Sep 2005 16:56:18 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. 'a'+1 (was: Baffling malloc problem)

2. Baffled by a linker message...

3. Baffled by my first C# ASP.NET project

4. a baffling mem allocation error

5. Message queues (baffling problem) [long]

6. Very Baffling evaluation with double

7. Need help with baffling bug

8. Baffling atan behavior!

9. STL set across modules - BAFFLED

10. Baffled by segmentation fault using GCC 2.5.8

11. Baffled by Borland C

12. Baffled by Borland C 4.0

 

 
Powered by phpBB® Forum Software