question

tmiguel-0268 avatar image
0 Votes"
tmiguel-0268 asked tmiguel-0268 commented

Need to get real OS Version

Hi need to get the real OS Version of the current machine in C++.
Essentially I need something similar to "GetVersionExW", but a version of it that:
1. Is not deprecated
2. Does not require the application to be explicitly manifested for the targeted OS version.
Note: Using "GetVersionExW" or any of the "version helper functions" (https://docs.microsoft.com/en-us/windows/win32/sysinfo/version-helper-apis)
is not acceptable, given that the application needs to be specifically manifested before they even work correctly and will not work to retrieve information about yet untargeted versions.

How can I do this? Is there already an existing function to do this? Can we have this added to Windows API?


This is extremely important to be able to remotely diagnose issues related to the target OS, and be able to remotely target specific content to those devices.
There should be no special configuration required, the only thing the application needs is to be able to run on the Windows device.

Ex usage 1. Client downloads and runs a managed software distribution application (SDA), the SDA may have only be manifested for up to Windows 10, but the SDA can get the real Windows version (ex Windows 11) be able to communicate with a repository that has a knowledge base for the current operating system and download a version of the intended software specifically optimized for a Windows 11 experience.

Ex usage 2. Client is running an application but faces usability issues related to how a custom Window appears on their desktop. They should be able to use an integrated system to be able to report the problem via the app itself, and allow us to figure out that they are running a version of Windows that we haven't tested yet.

Thanks

windows-apic++
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Castorix31 avatar image
2 Votes"
Castorix31 answered tmiguel-0268 commented

You can use RtlGetVersion
But for Windows 11, it is atm identified by the Build Number (>= 22000)

                     HMODULE hDll = LoadLibrary(TEXT("Ntdll.dll"));
                     typedef NTSTATUS(CALLBACK* RTLGETVERSION) (PRTL_OSVERSIONINFOW lpVersionInformation);
                     RTLGETVERSION pRtlGetVersion;
                     pRtlGetVersion = (RTLGETVERSION)GetProcAddress(hDll, "RtlGetVersion");
                     if (pRtlGetVersion)
                     {
                         RTL_OSVERSIONINFOW ovi = { 0 };
                         ovi.dwOSVersionInfoSize = sizeof(ovi);
                         NTSTATUS ntStatus = pRtlGetVersion(&ovi);
                         if (ntStatus == 0)
                         {                            
                             WCHAR wsMessage[255] = L"";
                             wsprintf(wsMessage, L"RtlGetVersion :\r\nMajor Version : %d\r\nMinor Version : %d\r\nBuild Number : %d", ovi.dwMajorVersion, ovi.dwMinorVersion, ovi.dwBuildNumber);
                             MessageBox(NULL, wsMessage, L"Information", MB_OK | MB_ICONINFORMATION);
                         }
                     }

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

That works like a charm. Thanks!

0 Votes 0 ·