Windows 10 not detecting on installshield

2019-01-20 18:55发布

问题:

Have requirement to detect windows 10 or greater version on install time. for that I have create following function.

It gives me 603 (AS VersionNT value) in windows 10 and windows 8.1. That is wrong.

Is there any other way to achieve this?

function BOOL isWindows10OrGreater()
 STRING svWindowsValue;
 NUMBER nWindowsValue;
 NUMBER nBuffer;
begin
     try
       nBuffer = 256;
       MsiGetProperty(ISMSI_HANDLE,"VersionNT",svWindowsValue,nBuffer);
       StrToNum(nWindowsValue,svWindowsValue);
       return (nWindowsValue >= 603);
     catch
       return FALSE;
    endcatch;
 end;

回答1:

Windows 10 - A Version Oddity


Disclaimer: this information is to the best of my knowledge as of now (check last edit date). This issue is sort of a "moving target" - things seem to change slightly for every OS release.


This is news to me as well, but it seems detecting Windows 10 is now a rather peculiar affair due to how core Win32 calls no longer are guaranteed to report the actual Windows version - and neither do VersionNT or VersionNT64 on my box. They both report 603 (which is Win 8 SP1). The explanation is here: VersionNT value for Windows 10 and Windows Server 2016.

Manifests & Versions: Whether your application is manifested or not is crucial here. Rather than repeating the explanation, I will link to this one (essential reading): C++ How to detect Windows 10.

"Evergreen Versionlessness": On the Microsoft rationale to do this (fight version checks - link to specific comment): Getting Windows OS version programmatically. So I suppose the question is if you should do such a version check at all - or so they want use to believe.


Installshield 2015 / 2018

I don't have Installshield available to test these features:

  • The 2015 Installshield help file has a blurb on Windows 10 detection in its what's new section.
    • SYSINFO.WINNT.bWin10 - with a note stating "This member is applicable to event-based InstallScript code; it is not applicable to InstallScript custom actions."
    • ISOSL_WIN10 (scroll down until you see the entry highlighted. Same for above link).
  • I assume this means that these structures and features only work in Installscript projects.

Workarounds?

I want to emphasize that these are workarounds and nothing else. We are supposed to check functionality these days and not OS versions. Test thoroughly please. I want to cross-link a similar answer with some "intel": VersionNT MSI property on Windows 10.

  1. OS File Version: MSDN suggests getting the version of a key OS file to determine if you are on Windows 10: Getting the system version. There seems to be an implementation of this in the bottom function here (untested).

  2. WindowsBuild property: It looks like the WindowsBuild property might be useable. It reports 9600 on my Windows 10 system. MSDN documentation for WindowsBuild with the different values for different OS versions. Remember that this value will increment with new releases, so you can't do an equal compare condition. You must do equal or higher. This is all to the best of my knowledge as of now.

  3. Registry: Maybe it is also an option to read these new registry values in order to determine if you are on Window 10 or not? Heaven knows what they will do with these keys in the future though? Are they "stable"?

    • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\

      • CurrentMajorVersionNumber = 10
      • CurrentMinorVersionNumber = 0
    • Reliable way to get Windows Version from registry

  4. WMI: I see suggestions to use WMI (not properly tested by me - just listing all possible options for those who have the test machines available to verify).


Links

Here are some further links. They are not recommendations, as much as a bunch of links used to assemble the above information - so they are here for "safekeeping". I will leave them as they are. There may be some inaccuracies here and there:

  • VersionNT MSI property on Windows 10
  • C++ How to detect Windows 10
  • https://blogs.msdn.microsoft.com/oldnewthing/20170112-00/?p=95175
  • C++ Check if Windows 10
  • Detecting Windows 10 version
  • https://www.advancedinstaller.com/forums/viewtopic.php?t=34212
  • https://msdn.microsoft.com/en-us/library/windows/desktop/dn424972(v=vs.85).aspx
  • https://msdn.microsoft.com/en-us/library/windows/desktop/dn905474(v=vs.85).aspx
  • https://msdn.microsoft.com/en-us/library/windows/desktop/ms647003.aspx