Wednesday, 21 August 2013

windows 8 minor version returning 0 instead of 2

windows 8 minor version returning 0 instead of 2

I have code in C++ that has the purpose of finding the Windows version:
OSVERSIONINFOEX osvi;
BOOL bOsVersionInfoEx;
int iRet = OS_UNKNOWN;
ZeroMemory ( & osvi, sizeof ( OSVERSIONINFOEX ) );
osvi.dwOSVersionInfoSize = sizeof ( OSVERSIONINFOEX );
if ( !( bOsVersionInfoEx = GetVersionEx ( ( OSVERSIONINFO * ) & osvi ) ) )
{
osvi.dwOSVersionInfoSize = sizeof ( OSVERSIONINFO );
if ( ! GetVersionEx ( ( OSVERSIONINFO * ) & osvi ) )
return OS_UNKNOWN;
}
//the rest is irrelevant ...
iRet will return an internal enum value identifying the Windows version.
It will be ajusted according to the values returned in osvi.dwPlatformId,
osvi.dwMajorVersion and osvi.dwMinorVersion.
According to MSDN, for Windows 8 the value of MajorVersion is 6 and the
value for MinorVersion is 2.
I have this code compiled in a dll and the code actually works if I call
the DLL from a test EXE program.
But if I call THE SAME CODE FROM THE SAME DLL from within a Custom Action
within a windows installer package (MSI), GetVersionEx() returns 0 for the
MinorVersion field.
Did anybody else experience this bug? Does anybody know how to work around
it?

No comments:

Post a Comment