dcsimg
Results 1 to 22 of 22

Thread: [RESOLVED] How to obtain "Version" number of Windows 10?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2014
    Posts
    188

    Resolved [RESOLVED] How to obtain "Version" number of Windows 10?

    When I right click on "System" menu, I got some pieces of info of my system, such as

    Edition: Windows 10 Home
    Version: 1709

    I know how to arrive at "Windows 10" in the above "Edition", but I don't know how to obtain the value of "1709" in the above "Version".

    Can any one help, using API only (not through Registry or WMI)?
    Last edited by Brenker; Feb 6th, 2018 at 08:22 PM.

  2. #2
    Fanatic Member
    Join Date
    Sep 2012
    Posts
    995

    Re: How to obtain "Version" number of Windows 10?


  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2014
    Posts
    188

    Re: How to obtain "Version" number of Windows 10?

    Thanks, dreammanor.

    I've looked at the subject posting, it relies on Registry, hence not meeting the criteria:
    If MajorMinor_ >= 10 Then
    'Get ReleaseId for Windows 10
    tmp = RegRead_REG_SZ("SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId")
    If IsNumeric(tmp) Then ReleaseId_ = CLng(tmp)
    End If
    There is a good example of getting "Edition: 'Windows 10" at http://www.cyberactivex.com/UnicodeT...ileVersionInfo (see "FileVersionInfo(2)" there), although I use a different approach (by resorting to Kernel32.dll file version). In this example, Registry and WMI are avoided, and no manifest required. However, that example doesn't demonstrate a way to obtain "Version: 1709" .

  4. #4
    Addicted Member
    Join Date
    Feb 2014
    Posts
    252

    Re: How to obtain "Version" number of Windows 10?

    The version number for Windows 10 is the YYMM of release. The only source to find is the registry ReleaseId, although I understand this is not the answer you looking for.

    Where that MinorVersion spot is for Service Pack number, Microsoft has done away with Service Pack for Windows 10, so that spot is now always "0" as in:
    10.0.10240 = ver 1507 (2015 Jul) Initial
    10.0.10586 = ver 1511 (2015 Nov) November Update
    10.0.14393 = ver 1607 (2016 Jul) Anniversary Update
    10.0.15063 = ver 1703 (2017 Mar) Creators Update
    10.0.16299 = ver 1709 (2017 Sep) Creators Fall Update
    10.0.????? = ver 18?? (2018 ???)
    Last edited by chosk; Feb 7th, 2018 at 05:19 AM.

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    4,493

    Re: How to obtain "Version" number of Windows 10?

    Here's all my related stuff. Also note that sometimes it's related to compatibility settings (i.e., shims) and sometimes it's not.

    Code:
    
    Option Explicit
    '
    Private Type OSVERSIONINFOW
    ' used by API call GetVersionExW
     dwOSVersionInfoSize As Long
     dwMajorVersion As Long
     dwMinorVersion As Long
     dwBuildNumber As Long
     dwPlatformId As Long
     szCSDVersion(1 To 256) As Byte
    End Type
    '
    Private Declare Function GetVersionExW Lib "kernel32" (lpOSVersinoInfo As OSVERSIONINFOW) As Long
    '
    
    Public Function WindowsVersion() As Long
        '
        ' This is independent of any manifest or any compatibility settings.
        '
        '    OS              WindowsVersion return
        ' Windows 10                100
        ' Windows 8.1                63
        ' Windows 8.0                62
        ' Windows 7                  61
        ' Windows Vista              60
        ' Windows XP                 51
        ' Windows 2000               50
        '                            -1 failed.
        Static lVersion As Long
        Dim SystemSet As Object
        Dim System As Object
        Dim s As String
        Dim i As Long
        '
        If lVersion Then
            WindowsVersion = lVersion
            Exit Function
        End If
        '
        On Error Resume Next
            Set SystemSet = GetObject("winmgmts:").InstancesOf("Win32_OperatingSystem")
            For Each System In SystemSet: s = System.Version: Next
            '
            i = InStr(s, ".")
            s = Left$(s, i - 1) & Mid$(s, i + 1)
            i = InStr(s, ".")
            If i Then s = Left$(s, i - 1)
            lVersion = Val(s)
            WindowsVersion = lVersion
        On Error GoTo 0
    End Function
    
    Public Function WindowsVersionMajor() As Long
        '
        ' Dependent on compatibility settings and also information in manifest.
        '
        '    OS                 dwMajorVersion  dwMinorVersion
        ' Windows 7                  6               1
        ' Windows Server 2008 R2     6               1
        ' Windows Server 2008        6               0
        ' Windows Vista              6               0
        ' Windows Server 2003 R2     5               2
        ' Windows Server 2003        5               2
        ' Windows XP                 5               1
        ' Windows 2000               5               0
        '
        Dim osinfo As OSVERSIONINFOW
        osinfo.dwOSVersionInfoSize = LenB(osinfo)
        GetVersionExW osinfo
        WindowsVersionMajor = osinfo.dwMajorVersion
        '
        'Dim osinfo As OSVERSIONINFO
        'osinfo.dwOSVersionInfoSize = 148
        'GetVersionExA osinfo
        'WindowsVersionMajor = osinfo.dwMajorVersion
    End Function
    
    Public Function WindowsVersionMinor() As Long
        '
        ' Dependent on compatibility settings and also information in manifest.
        '
        '    OS                 dwMajorVersion  dwMinorVersion
        ' Windows 7                  6               1
        ' Windows Server 2008 R2     6               1
        ' Windows Server 2008        6               0
        ' Windows Vista              6               0
        ' Windows Server 2003 R2     5               2
        ' Windows Server 2003        5               2
        ' Windows XP                 5               1
        ' Windows 2000               5               0
        '
        Dim osinfo As OSVERSIONINFOW
        osinfo.dwOSVersionInfoSize = LenB(osinfo)
        GetVersionExW osinfo
        WindowsVersionMinor = osinfo.dwMinorVersion
        '
        'Dim osinfo As OSVERSIONINFO
        'osinfo.dwOSVersionInfoSize = 148
        'GetVersionExA osinfo
        'WindowsVersionMinor = osinfo.dwMinorVersion
    End Function
    
    Public Function WindowsServicePack() As String
        Dim osinfo As OSVERSIONINFOW
        osinfo.dwOSVersionInfoSize = LenB(osinfo)
        GetVersionExW osinfo
        WindowsServicePack = RTrimNull(CStr(osinfo.szCSDVersion))
        '
        'Dim osinfo As OSVERSIONINFO
        'osinfo.dwOSVersionInfoSize = 148
        'GetVersionExA osinfo
        'WindowsServicePack = RTrimNull(osinfo.szCSDVersion)
    End Function
    
    Public Function WindowsPlatform() As String
        '
        ' Dependent on compatibility settings and also information in manifest.
        '
        Dim osinfo As OSVERSIONINFOW
        '
        osinfo.dwOSVersionInfoSize = LenB(osinfo)
        GetVersionExW osinfo
        '
        Select Case osinfo.dwPlatformId
        Case 1
            WindowsPlatform = "9X" ' Includes ME
        Case 2
            WindowsPlatform = "NT" ' Includes 2000 and XP
        Case Else
            WindowsPlatform = "Failed"
        End Select
    End Function
    
    Public Function RTrimNull(s As String) As String
        Dim i As Integer
        i = InStr(s, vbNullChar)
        If i Then
            RTrimNull = Left$(s, i - 1)
        Else
            RTrimNull = s
        End If
    End Function
    
    
    
    Enjoy,
    Elroy
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2014
    Posts
    188

    Re: How to obtain "Version" number of Windows 10?

    Thank you, Elroy.

    I've browsed the code lines you provided; that doesn't yield me any additional info I need. As I mentioned earlier, I already know how to arrive at "Edition: Windows 10 Home" (the data I've already got being "Windows 10" + "Home" + "10.0.16299" which is identical to what Windows system screen shows).

    What I am looking for is: How to obtain the value of "1709" in "Version: 1709", through API without engaging Registry or WMI.
    Last edited by Brenker; Feb 7th, 2018 at 11:28 PM.

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    18,964

    Re: How to obtain "Version" number of Windows 10?

    The ReleaseID is more of a marketing confection than anything else.

    Since programs shouldn't be looking at it anyway there was no reason to make a Win32 call to retrieve it. If you want it read it from the registry. That's all WMI does anyway.

  8. #8
    Addicted Member
    Join Date
    Feb 2014
    Posts
    252

    Re: How to obtain "Version" number of Windows 10?

    Quote Originally Posted by Brenker View Post
    What I am looking for is: How to obtain the value of "1709" in "Version: 1709", through API without engaging Registry or WMI.
    Short of convincing Microsoft to add this into the API and only if they are willing but if there is none and the Registry is to be avoided at all cost, then an option is to infer the Version number from the Build number. These Build numbers are fixed for the Version numbers on official releases:

    10240 = ver 1507
    10586 = ver 1511
    14393 = ver 1607
    15063 = ver 1703
    16299 = ver 1709

    Any other Build number will be Insider Preview. They released many Insider Preview Build along the way. Example just yesterday they released Insider Preview Build 17093. Just ignore or infer these Builds as Unknown.

  9. #9
    Addicted Member
    Join Date
    Feb 2014
    Posts
    252

    Re: How to obtain "Version" number of Windows 10?


  10. #10
    Addicted Member
    Join Date
    Feb 2014
    Posts
    252

    Re: How to obtain "Version" number of Windows 10?

    Deleted. Duplicate.
    Last edited by chosk; Feb 8th, 2018 at 12:53 AM. Reason: Duplicate post

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Sep 2014
    Posts
    188

    Re: How to obtain "Version" number of Windows 10?

    Chosk,

    I thank you for your comments in the above which are not only constructive, but also sensible. Indeed, in the absence of a known API, your suggestion should be a way out, especially when MS gives the next Build in advance. I shall leave this thread open for a few days before marking it "Resolved".

    On several occasions I had come across people saying that to obtain "Windows 10", a manifest is required. The two approaches mentioned in my earlier posting (# 3) have negated that and both approaches result in the same Major, Minor and Build pertaining to Windows 10.

    Brenker

  12. #12
    Lively Member jj2007's Avatar
    Join Date
    Dec 2015
    Posts
    94

    Re: How to obtain "Version" number of Windows 10?

    Quote Originally Posted by Brenker View Post
    using API only
    RtlGetNtVersionNumbers works reliably, and ignores compatibility settings - be sure that this is what you want. We had several threads on this problem at the Masm32 forum, see e.g. Retrieving Windows OS Version. Micros**t made a genuine mess there

  13. #13
    PowerPoster
    Join Date
    Feb 2006
    Posts
    18,964

    Re: How to obtain "Version" number of Windows 10?

    Application and assembly manifests do a lot more than this though. There is no reason to fear them and they can actually do your programs a lot of good.

  14. #14

    Thread Starter
    Addicted Member
    Join Date
    Sep 2014
    Posts
    188

    Re: How to obtain "Version" number of Windows 10?

    Thank you, jj2007.

    Judging from its parameters, RtlGetNtVersionNumbers would return Major, Minor & Build only. As such, it is not what I want, because I already have them.

  15. #15
    Lively Member jj2007's Avatar
    Join Date
    Dec 2015
    Posts
    94

    Re: How to obtain "Version" number of Windows 10?

    Quote Originally Posted by Brenker View Post
    Judging from its parameters, RtlGetNtVersionNumbers would return Major, Minor & Build only.
    The third parameter is a pointer to an integer that receives, in its loword, the build number.

    Besides, major & minor may differ from what you receive from other functions. As mentioned above, RtlGetNtVersionNumbers returns the true info about the OS, not taking into account compatibility settings or registry entries of any kind. The info is hardcoded into ntdll, as documented here. For example: mov dword ptr [eax], F0001DB1 ; $1DB1=7601
    Last edited by jj2007; Feb 8th, 2018 at 08:29 PM. Reason: added link to disassembly

  16. #16

    Thread Starter
    Addicted Member
    Join Date
    Sep 2014
    Posts
    188

    Re: How to obtain "Version" number of Windows 10?

    jj2007,

    ...... RtlGetNtVersionNumbers returns the true info about the OS, not taking into account compatibility settings or registry entries of any kind. The info is hardcoded into ntdll, as documented here. For example: mov dword ptr [eax], F0001DB1 ; $1DB1=7601
    "...... ntdll", no wonder it gets correct Major and Minor on Windows 10.

    What I meant in my previous posting was that using my existing subroutine, I would also get the same correct Major, Minor and Build.

    While we are here, just a chatty:

    Since long my assembly had got rotten, not just rusted, and I believe today's MASM is of entirely different kind. The last version of MASM I used was 6.0 (you can tell in what era) when many of our programs were written for either ".COM" or ".EXE". I didn't do many though; the biggest one was mimicking Peter Norton's Hex Editor. In the first .ASM file of a program, I had something like this:

    DOSSEG ;segment ordering convention
    .MODEL SMALL ;Upto 64K code & 64K data stack
    .STACK 4096
    .DATA
    .........

    I even had to define graphic chars to be used for the frame of the main menu:

    VERT_BAR EQU 0BAH
    HORIZ_BAR EQU 0CDH
    UPPER_LEFT EQU 0C9H
    .........

    At that time, every programmer would have a Peter Norton's book "DOS" on his/her desk (even for an amateur like myself), as a ready reference when coding assembly (MSDN was beyond imagination then).

    "Those were the days". Why I picked up assembly at that time? Because I marvelled at Lotus. For several years I mainly did dBase of the then Ashton-Tete/Borland's though, creating utilities to ease my job while I was a professional accountant (FCMA of UK, AHKSA of HongKong, CPA of Canada).

    Nowadays I do graphics programming as a hobby only, no pressure, but lots of curiosity.

    Thanks again for your being of help.


    Brenker

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Sep 2014
    Posts
    188

    Re: How to obtain "Version" number of Windows 10?

    On Windows 7, the system information would show, e.g.
    6.1.7601 (Major.Minor.Build)
    Service Pack 1
    We know we can obtain all of the above pieces, including "Service Pack 1".

    On Windows 10, the system information would show a bit differently, e.g.
    10.0.16299 (Major.Minor.Build)
    Version 1709
    This time, we still can obtain Major, Minor & Build, but we don't know how to arrive at "Version 1709".

    To seek an answer, this thread has thus been created. Specifically, the question is, how to obtain the value of "1709" in the above-said "Version: 1709", through API without engaging Registry or WMI.

    It seems such an API is not available (yet), therefore this thread is considered closed.

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Sep 2014
    Posts
    188

    Re: [RESOLVED] How to obtain "Version" number of Windows 10?

    Chosk,

    Following your posting #8, in which you put forward a hard coded approach to arrive at "1709", I've this morning found out something new.

    I said that from kernel32.dll file version we can also obtain Major, Minor and Build of Windows 10. Now if I extend the code to call FileTimeToLocalFileTime and FileTimeToSystemTime, I get its file stamp as follows:

    09/09/2017

    If we take the last two digits of the year, plus the two digits of the month, then we can form a "1709" - this squarely fits to "Version: 1709" in my posting #1.

    I would say this is an interesting beat about the bush, so I come back to let you know it.

    Brenker

  19. #19
    Lively Member jj2007's Avatar
    Join Date
    Dec 2015
    Posts
    94

    Re: [RESOLVED] How to obtain "Version" number of Windows 10?

    Quote Originally Posted by Brenker View Post
    if I extend the code to call FileTimeToLocalFileTime and FileTimeToSystemTime, I get its file stamp as follows:

    09/09/2017

    If we take the last two digits of the year, plus the two digits of the month, then we can form a "1709" - this squarely fits to "Version: 1709" in my posting #1.
    Interesting indeed, but how meaningful is this "version"? My current Win7-64 does not show a version in system info, just the build number; and kernel32.dll dates 1 January 2018...

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Sep 2014
    Posts
    188

    Re: [RESOLVED] How to obtain "Version" number of Windows 10?

    Hi jj2007,

    The OS on my Win 10 machine is not upgraded from Win 7; it was there when I bought the machine. If I right click on Start button, there is a listing showing some menu items and one of them is "System" - the system spec is invoked by a right click on it. On my Win 7 machine, which is without a Win 10 upgrade, it would show "Windows 7 Home" and "Service Pack 1", on my clicking "System" in Control Panel.

    Attached are a cropped screenshot of the system spec screen on my Win 10 and a screenshot of the system info from my own programs. Although I said that nowadays I did graphics programming as a hobby only, actually a few years earlier I had been selling some serious programs in the market via CNET etc download sites, including a Paint program, a full-fledged Icon Editor and a full-featured animated GIF editor (since right after Unisys stopped its renewal of GIF LZW patent). During those years, customers might ask questions; sometimes I would ask them to click a menu and send me the resulting system info, as this would help me diagnose their problems. I still maintain this system info menu in my programs, despite nowadays my programs are given out on a gratuitous basis (meanwhile I am still maintaining contact with some of the old customers).

    Since "Version 1709" is tied to Build, it doesn't matter whether we show it or not. I wanted to know where it came from, mainly to satisfy my curiosity, but also because nowadays people often talk of "I am on Windows 10, Version 1709".

    Edited:
    For easy reference, the actual code for obtaining YY and MM is attached below:
    Code:
    '========================================================================
    'Windows 10 doesn't have Service Pack, but it has a new "Version" reference which is formed
    'by YYMM
    '---------------------------------------------------------------------------------------------
    Private Function FileModifiedYYMMDD(ByVal inFileSpec As String) As Boolean
        Dim typLocalTime As FILETIME
        Dim typSysTime As SYSTEMTIME
        Dim Win32Data As WIN32_FIND_DATA
        Dim mHandle As Long
        
        On Error GoTo errHandler
        If IsFileThere(inFileSpec) Then
            mHandle = FindFirstFile(inFileSpec, Win32Data)
            If mHandle <> 0 Then
                FileTimeToLocalFileTime Win32Data.ftLastWriteTime, typLocalTime
                FileTimeToSystemTime typLocalTime, typSysTime
                m_ModifiedYear = Format(typSysTime.wYear, "0000")
                m_ModifiedMonth = Format(typSysTime.wMonth, "00")
                FindClose mHandle
                FileModifiedYYMMDD = True
            End If
        End If
        Exit Function
    errHandler:
    End Function

    Brenker
    Attached Images Attached Images   
    Last edited by Brenker; Feb 14th, 2018 at 11:31 AM.

  21. #21

    Thread Starter
    Addicted Member
    Join Date
    Sep 2014
    Posts
    188

    Re: [RESOLVED] How to obtain "Version" number of Windows 10?

    The latest Windows 10 update has proved that the Kernel32.dll file stamp approach, as stated above, is not always accurate. Officially the latest status should be "Version 1803", not "Version 1804" (which the said file stamp approach would otherwise result).

    It seems that after all, the Registry approach as suggested by Dreammanor in posting #2, has to be resorted to.

    Brenker

  22. #22
    Lively Member jj2007's Avatar
    Join Date
    Dec 2015
    Posts
    94

    Re: [RESOLVED] How to obtain "Version" number of Windows 10?

    My code doesn't use the version number, but the build number is correctly found as 16299
    The Windows specs say Win10 home, version 1709 (whatever that means), build 16299.371

    Note that you can indeed get the version number from HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion, ReleaseID; but that key is not present in older Windows versions, e.g. Win7.
    Last edited by jj2007; May 5th, 2018 at 11:33 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width