Recent

Author Topic: Windows version  (Read 4909 times)

Mando

  • Full Member
  • ***
  • Posts: 181
Windows version
« on: January 05, 2011, 11:39:41 am »
Hello all:

I need to know the version of windows in wich my program runs.
How can i reach this?

regards.

typo

  • Hero Member
  • *****
  • Posts: 3051

jmnj

  • Newbie
  • Posts: 4
Re: Windows version
« Reply #2 on: June 17, 2020, 05:57:46 pm »
I use the recommendation from here...

https://wiki.freepascal.org/WindowsVersion

Worked for me.

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 835
    • Lebeau Software
Re: Windows version
« Reply #3 on: June 17, 2020, 09:43:10 pm »
http://msdn.microsoft.com/en-us/library/ms724451%28v=vs.85%29.aspx

That doesn't work reliably anymore since Windows 8.1 onwards.  That same page explains why:

Quote
With the release of Windows 8.1, the behavior of the GetVersionEx API has changed in the value it will return for the operating system version. The value returned by the GetVersionEx function now depends on how the application is manifested.

Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2). Once an application is manifested for a given operating system version, GetVersionEx will always return the version that the application is manifested for in future releases.

If you don't manifest your app correctly, GetVersionEx() won't report the actual Windows version:

- If you don't manifest at all, it will report 8.0 when running on 8.1+.

- If you manifest only up to 8.1, it will report 8.1 when running on 10.0+.

- If you manifest only up to 10.0, it will report 10.0 when running on 10.1+.

And so on...

Every time a new version of Windows is released that requires a new manifest entry, you have to retest your app on that version and update your manifest accordingly so that Windows knows the app is compatible with that new version, otherwise Windows will dummy itself down for the version(s) that your app actually claims to support.

A more reliable way (for now) is to use RtlGetVersion() instead, as it is not subject to manifestation (yet?).

I use the recommendation from here...

https://wiki.freepascal.org/WindowsVersion

Worked for me.

That approach (using GetVersion()) is subject to the same manifest issue as GetVersionEx() on Windows 8.1 onward.
« Last Edit: June 17, 2020, 09:52:36 pm by Remy Lebeau »
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

ASerge

  • Hero Member
  • *****
  • Posts: 1692
Re: Windows version
« Reply #4 on: June 17, 2020, 09:46:16 pm »
If you don't manifest your app correctly then you won't get a correct version reported.
Applications on Lazarus have the correct manifest.

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 835
    • Lebeau Software
Re: Windows version
« Reply #5 on: June 17, 2020, 09:55:08 pm »
Applications on Lazarus have the correct manifest.

So, every time a new Windows is released that requires a new manifest entry, Lazarus is updated to add that entry automatically?

It really should not be Lazarus' responsibility to manage the OS version entries of the manifest.  The user should do that manually, based on the OS versions that they have actually tested their app on.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

ASerge

  • Hero Member
  • *****
  • Posts: 1692
Re: Windows version
« Reply #6 on: June 17, 2020, 10:19:17 pm »
So, every time a new Windows is released that requires a new manifest entry, Lazarus is updated to add that entry automatically?
Yes. It's normal.
Quote
It really should not be Lazarus' responsibility to manage the OS version entries of the manifest.
Lazarus makes sure that the app works correctly even in the latest versions. This is also normal.

RtlGetVersion this is a very special function for applications that for some reason do not have a manifest or deliberately hide from the OS about their ability to work with the latest versions.
« Last Edit: June 17, 2020, 10:22:43 pm by ASerge »

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 835
    • Lebeau Software
Re: Windows version
« Reply #7 on: June 18, 2020, 03:14:54 am »
Lazarus makes sure that the app works correctly even in the latest versions. This is also normal.

Well, that does require users to update to a new Lazarus after it has been updated to support a new Windows version.  Not everyone upgrades right away.  And besides, just because the RTL/LCL frameworks that Lazarus provides work with certain Windows versions, doesn't necessarily mean that user's code does.  Hence why users should test their apps and then configure their manifests accordingly.

RtlGetVersion this is a very special function for applications that for some reason do not have a manifest or deliberately hide from the OS about their ability to work with the latest versions.

I have no idea what you are trying to say.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

PascalDragon

  • Hero Member
  • *****
  • Posts: 2397
  • Compiler Developer
Re: Windows version
« Reply #8 on: June 18, 2020, 09:29:27 am »
RtlGetVersion this is a very special function for applications that for some reason do not have a manifest or deliberately hide from the OS about their ability to work with the latest versions.

I have no idea what you are trying to say.

I think he refers to the point that RtlGetVersion like nearly all functions provided by NtDll are considered undocumented for the userspace. Thus by using them it might be that Microsoft changes them without you noticing (though to be fair considering Microsoft's backwards compatibility track record that is rather unlikely).

I agree however that Lazarus should provide more options to influence the manifest. Well, patches welcome I guess. ;)

440bx

  • Hero Member
  • *****
  • Posts: 2046
Re: Windows version
« Reply #9 on: June 18, 2020, 02:05:49 pm »
Just in case the OP might be interested.  The only Windows API that is known to always return the unadulterated truth about its version number is RtlGetNtVersionNumbers. 

Other APIs will either return what the program wants to "hear" or what Windows wants the program to "hear" and, neither may be the actual Windows version.

More information about that function is found in the thread https://forum.lazarus.freepascal.org/index.php/topic,46969.msg335900.html#msg335900

HTH.
« Last Edit: June 18, 2020, 02:08:47 pm by 440bx »
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 835
    • Lebeau Software
Re: Windows version
« Reply #10 on: June 19, 2020, 02:04:27 am »
Just in case the OP might be interested.  The only Windows API that is known to always return the unadulterated truth about its version number is RtlGetNtVersionNumbers. 

Good catch, I forgot about that function.
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

 

TinyPortal © 2005-2018