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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With