locked
API to Get Windows Version?

    Question

  • The GetVersionEx, GetProductInfo, and IWbemServices::GetObject (to get Win32_OperatingSystem) APIs are all desktop only. How do I get the Windows version?
    Monday, April 09, 2012 6:59 PM

All replies

  • Currently a constant 6.2 ?

    I think Windows version has no relation to the Metro App.


    C++ DX11

    Tuesday, April 10, 2012 1:32 AM
  • I don't understand. So all metro apps are to assume that windows will never be versioned? I'd like my companies bug reporting tools to include OS information.
    Tuesday, April 10, 2012 10:12 PM
  • I've no idea about the API. 

    But I think you can parse the system DLL's memory image PE in your process (like kernel32.dll) to get its File/Product Version. 

    Maybe you can get the image base through VirtualQuery and the address of available Win32 APIs. Then parse the version from .rsrc section. I don't know if there are any restrictions.


    C++ DX11

    • Edited by Raptor K Wednesday, April 11, 2012 3:02 AM
    Wednesday, April 11, 2012 2:52 AM
  • Even I want the "OS version" info. Can someone suggest a method?
    Friday, April 20, 2012 10:40 AM
  • Hi all,

    Here is my idea, for Win8 metro we could not find any OS version according to current WINRT API list: http://msdn.microsoft.com/en-us/library/windows/apps/br205757.aspx

    For your request, I would suggest you to fire your bug report program on desktop mode or IE.

    Refer  Association launching sample

    Best regards.

    Evan

    Friday, April 20, 2012 11:18 AM
  • Testing the OS version is a fragile (easy to get wrong as history has shown) and indirect way to decide if new functionality that the platform provides should be used by your application. A more direct and reliable way is to test for the presence of the runtimeclass or interface that offers that functionality and use it if it is available. No need to test a version value.

    This is why we don’t have a version API in WinRT or the MSDK.

    Chris

    Saturday, April 21, 2012 3:09 AM
  • OS versions, service pack information and hardware info has traditionally been logged along with exceptions occurring in software code, so that its easier for developers for trace the issue back to a particular version of the OS on particular hardware. I think its simplistic to assume that the only need for OS versions is during runtime for various code paths using varying OS functionality.

    Its disappointing that the Win32 apis to obtain OS version is excluded from Metro Style development, especially because Windows Runtime doesn't have a replacement for it.

    I tried using C++/CLI to use the .NET property System.Environment::OSVersion directly from within the C++/CX windows Runtime component I am working on, but the compiler complaints the C++/CLI and C++/CX switches are incompatible.

    This forces me create a windows runtime component in C# and expose the value to be used in my C++ code, arghh !

     
    Friday, June 22, 2012 7:59 PM
  • If you use WER (Windows Error Reporting) in your Metro apps, MS will provide the used Windows version and the version of all DLLs with the report to you.
    Monday, June 25, 2012 12:47 PM
  • Hi brentAtBrainium,

    There is no direct way to get the OS version from Metro app.

    please see this thread

    http://stackoverflow.com/questions/10125324/get-os-version-in-winrt-metro-app-c-sharp

    There is no relevance in checking OS version from Metro app.

    As WinRT is available only for windows8!!

    thanks,

    Bhash

    Friday, June 29, 2012 1:58 PM
  • > As WinRT is available only for windows8!!

    Yes...  but when for example your trying to track bug reports, knowing the OS version is useful.

    This is something that should come back in some sort of information string about the OS.

      - Tom

    Monday, August 06, 2012 5:20 AM
    • Proposed as answer by Fmzhao Tuesday, May 05, 2015 3:31 AM
    Thursday, September 19, 2013 11:40 AM
  • BTW, the Win32 desktop GetVersion(Ex) APIs are also deprecated in the Windows 8.1 SDK.

    http://msdn.microsoft.com/en-us/library/windows/desktop/dn302074.aspx

    Friday, September 20, 2013 6:57 PM