[Incident]: Some users report they are unable to access the case portal. Please see this community notice for more information.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
chocodachs
Level 3

Check if WIndows 7 or not, usingGetVersionEx

I try to check if Windows 7 or not, using GetVersionEx in Install Script.
However, When I debugged as below Script in Windows 7, th nimber of nMinorVersion was returned 0. (The Number of nMajorVersion was correctlly returned 1.)

Could someone help me, please ?

// ----------------------------------------------------------------------
// InstallScript:
//
// ----------------------------------------------------------------------

#include "ifx.h"

export prototype MyFunction(HWND);

OSVERSIONINFOEX osvi;
BOOL bAns;

number nMajorVersion;
number nMinorVersion;

function MyFunction(hMSI)
begin
osvi.nOSVersionInfoSize = SizeOf(osvi);
bAns = GetVersionEx(&osvi);

nMajorVersion = osvi.nMajorVersion;
nMinorVersion = osvi.nMinorVersion;

end;
Labels (1)
0 Kudos
7 Replies
chocodachs
Level 3

There was a type miss in the Previous post.

The number of nMajorVersion was correctly 6.

Sorry
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

This API is known to intentionally report incorrect values in installers. You should reference the VersionNT property from your MSI.
0 Kudos
chocodachs
Level 3

Thank you, MichaelU.

As "idriver.exe" is running in compatible mode, GetVersionInfo returns the information incorrectly, I've heard.

In such a case, are nServicePackMajor and nServicePackMinor returned incorrect value ?
0 Kudos
Not applicable

Hello, chocodachs

Why not use SYSINFO structure?
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

I believe the SYSINFO struct is populated from the same incorrectly reported values, so it won't be any better. While we could reference VersionNT to build this in some cases, in other cases (like those invoked from deferred custom actions) this wouldn't work, and the disconnect would be much more risky.

Another approach to consider, depending on your needs, is to use the VerifyVersionInfo API instead. I don't believe it is as likely to lie, as it handles the check internally so an application's code is less likely to misuse it.
0 Kudos
chocodachs
Level 3

Hello, Kevin

Of course, I tried to use SYSINFO information.
But The below information is the same as GetInfoEx's.
SYSINFO.nOSMajor -> 6
SYSINFO.nOSMinor -> 0
SYSINFO.nWinMajor -> 6
SYSINFO.nWnMinor -> 0

Regards,
chocodachs
0 Kudos