How can I determine the Windows version from a VB 6 app?

后端 未结 7 911
野趣味
野趣味 2020-12-09 04:10

I want to detect any Windows versions from 95 to Win 7.

I also would like to display if the OS is 32-bit or 64-bit.

That\'s it; it\'s that simple. :) What co

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 04:35

    There's also the WMI Tasks for Operating Systems.

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set colOperatingSystems = objWMIService.ExecQuery ("Select * from Win32_OperatingSystem")
    For Each objOperatingSystem in colOperatingSystems
        Wscript.Echo objOperatingSystem.Caption & "  " & objOperatingSystem.Version
    Next
    

    You can do something similar to the case statements provided by Cody Gray above to parse the Version value, or parse the plain text Caption value, which has listings like Microsoft(R) Windows(R) Server 2003, Standard Edition and Microsoft Windows 7 Professional.

提交回复
热议问题