How to tell which version of Linux or Windows app is running on

I have a cross-platform GUI (fltk-rs) app (windows + linux).
I'd like the about box to say which distro & version it is running on on linux; and similarly which windows version when running on windows.
I know about env::{OS,ARCH}, but want a bit more detail.

1 Like

For linux you can check the kernel version using uname -r. For the specific distro you can try lsb_release -a if it is installed. For windows there is GetVersion(), but the docs warn

GetVersion may be altered or unavailable for releases after Windows 8.1.

And as alternative a list of functions to check if the windows version is at least a certain version is given: Version Helper functions - Win32 apps | Microsoft Docs The docs for GetVersionEx elaborate on this:

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. To manifest your applications for Windows 8.1 or Windows 10, refer to Targeting your application for Windows.

Basically it is useless to determine the actual OS version. Someone more familiar with windows will have to tell if there is another option that does still work.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.