pocoproject / poco

The POCO C++ Libraries are powerful cross-platform C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.
https://pocoproject.org
Other
8.19k stars 2.13k forks source link

Poco::Environment::osDisplayName #3180

Open micheleselea opened 3 years ago

micheleselea commented 3 years ago

the standard GetVersionEx returns always windows8 without a manifest. Probably should we use this implementation https://stackoverflow.com/questions/37700605/getting-windows-os-version-programmatically

BOOL GetTrueWindowsVersion(OSVERSIONINFOEX* pOSversion)
{
   // Function pointer to driver function
   NTSTATUS (WINAPI *pRtlGetVersion)(
      PRTL_OSVERSIONINFOW lpVersionInformation) = NULL;

   // load the System-DLL
   HINSTANCE hNTdllDll = LoadLibrary("ntdll.dll");

   // successfully loaded?
   if (hNTdllDll != NULL)
   {
      // get the function pointer to RtlGetVersion
      pRtlGetVersion = (NTSTATUS (WINAPI *)(PRTL_OSVERSIONINFOW))
            GetProcAddress (hNTdllDll, "RtlGetVersion");

      // if successfull then read the function
      if (pRtlGetVersion != NULL)
         pRtlGetVersion((PRTL_OSVERSIONINFOW)pOSversion);

      // free the library
      FreeLibrary(hNTdllDll);
   } // if (hNTdllDll != NULL)

   // if function failed, use fallback to old version
   if (pRtlGetVersion == NULL)
      GetVersionEx((OSVERSIONINFO*)pOSversion);

   // always true ...
   return (TRUE);
} // GetTrueWindowsVersion

that gives the correct version

micheleselea commented 3 years ago

Be aware that RtlGetVersion I think does not give you server/client information, for that I think we can call GetVersionEx before

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 365 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 60 days since being marked as stale.

github-actions[bot] commented 4 months ago

This issue was closed because it has been inactive for 60 days since being marked as stale.