首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > windows >

怎么用vb6获取操作系统的版本号(需要补充)

2012-02-26 
如何用vb6获取操作系统的版本号(需要补充)下面有一段网友给的获取操作系统的版本(区别windows系统版本):VB

如何用vb6获取操作系统的版本号(需要补充)
下面有一段网友给的获取操作系统的版本(区别windows系统版本):

VB code
Public Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As IntegerPublic Type OSVERSIONINFO   dwOSVersionInfoSize As Long   dwMajorVersion As Long   dwMinorVersion As Long   dwBuildNumber As Long   dwPlatformId As Long   szCSDVersion As String * 128End TypePublic Function GetVersion() As String   Dim osinfo As OSVERSIONINFO   Dim retvalue As Integer   osinfo.dwOSVersionInfoSize = 148   osinfo.szCSDVersion = Space$(128)   retvalue = GetVersionExA(osinfo)   With osinfo    Select Case .dwPlatformId        Case 1                Select Case .dwMinorVersion                    Case 0                        GetVersion = "Windows 95"                    Case 10                        GetVersion = "Windows 98"                    Case 90                        GetVersion = "Windows Mellinnium"                End Select        Case 2                Select Case .dwMajorVersion                    Case 3                        GetVersion = "Windows NT 3.51"                    Case 4                        GetVersion = "Windows NT 4.0"                    Case 5                        If .dwMinorVersion = 0 Then                            GetVersion = "Windows 2000"                        Else                            GetVersion = "Windows XP"                        End If                End Select         Case Else               GetVersion = "Failed"    End Select   End WithEnd Function



该代码有点缺陷:就是不能区别win2003、vista和win7

有哪位大侠有上述系统,帮俺给补充完整了,谢谢。。。。。。。


[解决办法]
最重要不就一句了,retvalue = GetVersionExA(osinfo)

这个与GetVersionExA()函数有关了,查ms的帮助

反正ver命令就可以查版本了,找下对应api了

BatchFile code
ver | find "5.0" >nul && (echo win2000)ver | find "5.1" >nul && (echo winxp)ver | find "5.2" >nul && (echo win2003)ver | find "6.0" >nul && (echo vista)ver | find "6.1" >nul && (echo win7) 

热点排行