How can I get a future version of a convenient version of the operating system?

This question, How to determine the version of Windows from a VB 6 application , has a very useful answer from Cody Gray, which uses GetVersionEx and the Select Case statement to return the version of Windows as a user-friendly string.

However, the specified code is limited in that all returned values ​​are hard-coded, which means that it is not future proof and should be rewritten every time a new version of Windows, such as Windows 8, is released.

Is there any other option, besides using GetVersionEx and the Select Case operator, to get a convenient operating system name, which will also be relatively promising?

+8
windows vb6
source share
1 answer

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 
+7
source share

All Articles