打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Excel FAQ 【网络应用】
userphoto

2018.12.05

关注

' By chijanzen

Private Declare Function GetVersionExA Lib "kernel32" _
(lpVersionInformation As OSVERSIONINFO) As Long

Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long      ' 此一資料結構的大小
dwMajorVersion As Long          ' 版本主編號, 例如 4.0.950 的 4
dwMinorVersion As Long          ' 版本次編號, 例如 4.0.950 的 0
dwBuildNumber As Long           ' 版本建立編號, 例如 4.0.950 的 950
dwPlatformId As Long            ' 作業平臺
szCSDVersion As String * 128    ' 版本的進一步說明
End Type
Public lpVersionInformation As OSVERSIONINFO
'VER_PLATFORM_WIN32s(= 0) Win32s, 可在 Win 3.1 底下執行 32 位元元應用程式的平臺
'VER_PLATFORM_WIN32_Windows(= 1)  Windows 95 或 98
'VER_PLATFORM_WIN32_NT(= 2)  Windows NT 或 200 或 XP


Sub ShowWVersion()
Dim s As String, a As String
a = OperatingSystem
Select Case a
Case 0: s = "Windows 32"
Case 1: s = "Windows 95"
Case 2: s = "Windows 98"
Case 3: s = "Windows ME"
Case 4: s = "Windows NT"
Case 5: s = "Windows 2000"
Case 6: s = "Windows XP"
End Select
MsgBox s
End Sub

Sub test()
MsgBox Application.OperatingSystem
End Sub

Public Function OperatingSystem() As Integer
lpVersionInformation.dwOSVersionInfoSize = Len(lpVersionInformation)
Call GetVersionExA(lpVersionInformation)
If (lpVersionInformation.dwPlatformId = 0) Then 'VER_PLATFORM_WIN32s(= 0) Win32s _
,可在 Win 3.1 底下執行 32 位元元應用程式的平臺
OperatingSystem = 0
    
ElseIf (lpVersionInformation.dwPlatformId = 1) And _
(lpVersionInformation.dwMinorVersion = 0) Then   'Win95:VER_PLATFORM_WIN32_Windows(= 1) _
dwMinorVersion = 0
OperatingSystem = 1
    
ElseIf (lpVersionInformation.dwPlatformId = 1) And _
(lpVersionInformation.dwMinorVersion = 10) Then   'Win98:VER_PLATFORM_WIN32_Windows(= 1) _
dwMinorVersion = 10
OperatingSystem = 2
    
ElseIf (lpVersionInformation.dwPlatformId = 1) And _
(lpVersionInformation.dwMinorVersion = 90) Then   'WinMe:VER_PLATFORM_WIN32_Windows(= 1) _
dwMinorVersion = 90
OperatingSystem = 3
    
ElseIf (lpVersionInformation.dwPlatformId = 2) And _
(lpVersionInformation.dwMajorVersion < 5) Then    'WinNT:VER_PLATFORM_WIN32_Windows(= 1) _
dwMinorVersion < 5
OperatingSystem = 4
    
ElseIf (lpVersionInformation.dwPlatformId = 2) And _
(lpVersionInformation.dwMajorVersion = 5) And _
(lpVersionInformation.dwMinorVersion = 0) Then    'Win2000:VER_PLATFORM_WIN32_Windows(= 1) _
dwMinorVersion=5 and dwMinorVersion = 0
OperatingSystem = 5
    
ElseIf (lpVersionInformation.dwPlatformId = 2) And _
(lpVersionInformation.dwMajorVersion = 5) And _
(lpVersionInformation.dwMinorVersion = 1) Then    'WinXP:VER_PLATFORM_WIN32_Windows(= 1) _
dwMinorVersion=5 and dwMinorVersion = 0
OperatingSystem = 6
    
End If
End Function


[此贴子已经被作者于2006-9-23 19:14:10编辑过]
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
VB获取操作系统版本信息
Windows系统版本判定那些事儿
GetVersionEx 获取系统版本信息
如何判断当前操作系统的版本
C#获取本地操作系统的版本(急!!)
Get The Name Of The Windows OS Installed on a Machine
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服