Windows version lazarus / 34-Windows ---------------------------------------------------------------------- Mando · 2011-01-05 10:39 Hello all: I need to know the version of windows in wich my program runs. How can i reach this? regards. ---------------------------------------------------------------------- typo · 2011-01-05 13:41 http://msdn.microsoft.com/en-us/library/ms724451%28v=vs.85%29.aspx ---------------------------------------------------------------------- jmnj · 2020-06-17 15:57 I use the recommendation from here... https://wiki.freepascal.org/WindowsVersion Worked for me. ---------------------------------------------------------------------- Remy Lebeau · 2020-06-17 19:43 Quote from: typo on January 05, 2011, 02:41:31 pmhttp://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: QuoteWith 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?). Quote from: jmnj on June 17, 2020, 05:57:46 pmI 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. ---------------------------------------------------------------------- ASerge · 2020-06-17 19:46 Quote from: Remy Lebeau on June 17, 2020, 09:43:10 pmIf 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 · 2020-06-17 19:55 Quote from: ASerge on June 17, 2020, 09:46:16 pmApplications 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. ---------------------------------------------------------------------- ASerge · 2020-06-17 20:19 Quote from: Remy Lebeau on June 17, 2020, 09:55:08 pmSo, 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. QuoteIt 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. ---------------------------------------------------------------------- Remy Lebeau · 2020-06-18 01:14 Quote from: ASerge on June 17, 2020, 10:19:17 pmLazarus 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. Quote from: ASerge on June 17, 2020, 10:19:17 pmRtlGetVersion 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. ---------------------------------------------------------------------- PascalDragon · 2020-06-18 07:29 Quote from: Remy Lebeau on June 18, 2020, 03:14:54 amQuote from: ASerge on June 17, 2020, 10:19:17 pmRtlGetVersion 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 · 2020-06-18 12:05 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://fo rum.lazarus.freepascal.org/index.php/topic,46969.msg335900.html#msg335 900 HTH. ---------------------------------------------------------------------- Remy Lebeau · 2020-06-19 00:04 Quote from: 440bx on June 18, 2020, 02:05:49 pmJust 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. ---------------------------------------------------------------------- Ericktux · 2020-12-07 04:32 Hi friend, here I share the code I use Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button3Click(Sender: TObject);begin  If (Win32MajorVersion=10) and (Win32MinorVersion=0) then ShowMessage('Tienes Windows 10');  if (Win32MajorVersion=6) and (Win32MinorVersion=3) then ShowMessage('Tienes Windows 8.1');  if (Win32MajorVersion=6) and (Win32MinorVersion=2) then ShowMessage('Tienes Windows 8');  if (Win32MajorVersion=6) and (Win32MinorVersion=1) then ShowMessage('Tienes Windows 7');  if (Win32MajorVersion=6) and (Win32MinorVersion=0) then ShowMessage('Tienes Windows Vista');  if (Win32MajorVersion=5) and (Win32MinorVersion=1) then ShowMessage('Tienes Windows XP');End; ---------------------------------------------------------------------- marcov · 2020-12-07 11:44 (I happened to be working on a fairly recent (created august) gui project, and there the manifest is off it seems, and I assume that is the default.) ---------------------------------------------------------------------- Peter H · 2020-12-07 14:02 Would the console command "systeminfo" help? Code: [Select]C:\lazarus\trunk\lazarus\examples\mousebuttons>systeminfo Hostname:                                      SIXCORE Betriebssystemname:                            Microsoft Windows 10 Pro Betriebssystemversion:                         10.0.19041 Nicht zutreffend Build 19041 Betriebssystemhersteller:                      Microsoft Corporation Betriebssystemkonfiguration:                   Eigenständige Arbeitsstation Betriebssystem-Buildtyp:                       Multiprocessor Free Registrierter Benutzer:                        peter Registrierte Organisation: Produkt-ID:                                      // I removed this ;) Ursprüngliches Installationsdatum:             19.11.2020, 17:52:47 Systemstartzeit:                               01.12.2020, 19:52:55 Systemhersteller:                              Acer Systemmodell:                                  Aspire M3300 Systemtyp:                                     x64-based PC Prozessor(en):                                 1 Prozessor(en) installiert.                                                [01]: AMD64 Family 16 Model 10 Stepping 0 AuthenticAMD ~2600 MHz BIOS-Version:                                  American Megatrends Inc. P03-B4, 18.08.2010 Windows-Verzeichnis:                           C:\WINDOWS System-Verzeichnis:                            C:\WINDOWS\system32 Startgerät:                                    \Device\HarddiskVolume2 Systemgebietsschema:                           de;Deutsch (Deutschland) Eingabegebietsschema:                          de;Deutsch (Deutschland) Zeitzone:                                      (UTC+01:00) Brüssel, Kopenhagen, Madrid, Paris Gesamter physischer Speicher:                  7.934 MB Verfügbarer physischer Speicher:               3.097 MB Virtueller Arbeitsspeicher: Maximale Größe:    16.126 MB Virtueller Arbeitsspeicher: Verfügbar:         6.503 MB Virtueller Arbeitsspeicher: Zurzeit verwendet: 9.623 MB [snip] ---------------------------------------------------------------------- Remy Lebeau · 2020-12-07 16:55 Quote from: Ericktux on December 07, 2020, 05:32:33 amHi friend, here I share the code I use The Win32(Major|Minor)Version variables use values from GetVersionEx(), and so are subject to the app's manifest, thus allowing Windows to lie about their values on Win8.1+.