Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get a future proof user friendly operating system version?

Tags:

windows

vb6

This question, How can I determine the Windows version from a VB 6 app, has a very useful answer from Cody Gray that utilises GetVersionEx and a Select Case statement to return the Windows Version as a user friendly string.

However the code given is limited in that all the return values are hard coded which means that it's not future proof and needs to be rewritten every time a new version of Windows comes out, like Windows 8, for example.

Is there any other option, other than using GetVersionEx and a Select Case statement, to retrieve a user friendly operating system name that will also be relatively future proof?

like image 272
Carl Onager Avatar asked Feb 18 '13 09:02

Carl Onager


Video Answer


1 Answers

The WMI classes can be used to extract the required data as follows:

Public Function GetFriendlyOSVersion() As String
    Dim query As String
    query = "SELECT Caption FROM Win32_OperatingSystem"
    Dim results As Object
    Set results = GetObject("Winmgmts:").ExecQuery(query)
    Dim info As Object
    For Each info In results
        GetFriendlyOSVersion = info.Caption
    Next info
End Function
like image 131
Carl Onager Avatar answered Nov 15 '22 03:11

Carl Onager