VB及VBA获取操作系统版本的通用模块
- 2017-09-19 08:00:00
- zstmtony 原创
- 3588
VB及VBA获取操作系统版本的通用模块
Option Explicit Public OSNameAs String'操作系统名称(简称),方便程序控制时根据操作系统取值 Public Type OSVERSIONINFO dwOSVersionInfoSize AsLong dwMajorVersion AsLong dwMinorVersion AsLong dwBuildNumber AsLong dwPlatformId AsLong szCSDVersion AsString * 128 wServicePackMajor AsInteger wServicePackMinor AsInteger wSuiteMask AsInteger wProductType AsByte wReserved AsByte End Type Public Declare Function GetVersionExLib "kernel32"Alias "GetVersionExA" (lpVersionInformationAs OSVERSIONINFO)As Long ' 获得 Windows 操作系统的名称,returnType决定返回的方式,值为0时,返回简称,否则返回全称 Public Function GetWindowsVersion(ByVal returnTypeAs Integer)As String Dim ver As OSVERSIONINFO, retLngAs Long, osAs String ver.dwOSVersionInfoSize =Len(ver) GetVersionEx ver ' retLng = GetVersionEx(ver) ' If retLng = 0 Then ' os = "Unknown System Version!" ' Exit Function ' End If With ver SelectCase .dwPlatformId Case1 SelectCase .dwMinorVersion Case0 If returnType= 0Then os ="Windows 95" Else SelectCase .szCSDVersion Case"C" os ="Windows 95 OSR2" Case"B" os ="Windows 95 OSR2" CaseElse os ="Windows 95" EndSelect EndIf Case10 If returnType= 0Then os ="Windows 98" Else SelectCase .szCSDVersion Case"A" os ="Windows 98 SE" CaseElse os ="Windows 98" EndSelect EndIf Case90 If returnType= 0Then os ="Windows Me" Else os ="Windows Millennium Edition" EndIf EndSelect Case2 SelectCase .dwMajorVersion Case3 os ="Windows NT 3.51" Case4 os ="Windows NT 4.0" Case5 SelectCase .dwMinorVersion Case0 If returnType= 0Then os ="Windows 2000" Else SelectCase .wSuiteMask Case&H80 os ="Windows 2000 Data center" Case&H2 os ="Windows 2000 Advanced" CaseElse os ="Windows 2000" EndSelect EndIf Case1 If returnType= 0Then os ="Windows XP" Else SelectCase .wSuiteMask Case&H0 os ="Windows XP Professional" Case&H200 os ="Windows XP Home" CaseElse os ="Windows XP" EndSelect EndIf Case2 If returnType= 0Then os ="Windows Server 2003" Else SelectCase .wSuiteMask Case&H2 os ="Windows Server 2003 Enterprise" Case&H80 os ="Windows Server 2003 Data center" Case&H400 os ="Windows Server 2003 Web Edition" Case&H0 os ="Windows Server 2003 Standard" ' Case &H112 ' os = "Windows Server 2003 R2 Enterprise" Case Else os ="Windows Server 2003" EndSelect EndIf EndSelect If returnType<> 0And .wServicePackMajor> 0Then os = os& " Service Pack" & .wServicePackMajor& IIf(.wServicePackMinor> 0,"."& .wServicePackMinor, vbNullString) EndIf Case6 If returnType<> 0Then SelectCase .wProductType Case&H6 os ="Business Edition" Case&H10 os ="Business Edition (N)" Case&H12 os ="Cluster Server Edition" Case&H8 os ="Server Datacenter Edition (full installation)" Case&HC os ="Server Datacenter Edition (core installation)" Case&H4 os ="Enterprise Edition" Case&H1B os ="Enterprise Edition (N)" Case&HA os ="Server Enterprise Edition (full installation)" Case&HE os ="Server Enterprise Edition (core installation)" Case&HF os ="Server Enterprise Edition for Itanium-based Systems" Case&H2 os ="Home Basic Edition" Case&H5 os ="Home Basic Edition (N)" Case&H3 os ="Home Premium Edition" Case&H1A os ="Home Premium Edition (N)" Case&H13 os ="Home Server Edition" Case&H18 os ="Server for Small Business Edition" Case&H9 os ="Small Business Server" Case&H19 os ="Small Business Server Premium Edition" Case&H7 os ="Server Standard Edition (full installation)" Case&HD os ="Server Standard Edition (core installation)" Case&H8 os ="Starter Edition" Case&H17 os ="Storage Server Enterprise Edition" Case&H14 os ="Storage Server Express Edition" Case&H15 os ="Storage Server Standard Edition" Case&H16 os ="Storage Server Workgroup Edition" Case&H1 os ="Ultimate Edition" Case&H1C os ="Ultimate Edition (N)" Case&H0 os ="An unknown product" Case&HABCDABCD os ="Not activated product" Case&H11 os ="Web Server Edition" EndSelect EndIf SelectCase .dwMinorVersion Case0 SelectCase .wProductType Case3 If returnType= 0Then os ="Windows Server 2008" Else os ="Windows Server 2008" & os EndIf CaseElse If returnType= 0Then os ="Windows Vista" Else os ="Windows Vista " & os EndIf EndSelect Case1 SelectCase .wProductType Case3 If returnType= 0Then os ="Windows Server 2008 R2" Else os ="Windows Server 2008 R2"& os EndIf CaseElse If returnType= 0Then os ="Windows 7" Else os ="Windows 7 " & os EndIf EndSelect EndSelect If returnType<> 0And .wServicePackMajor> 0Then os = os& " Service Pack" & .wServicePackMajor& IIf(.wServicePackMinor> 0,"."& .wServicePackMinor, vbNullString) EndIf EndSelect CaseElse os ="Unknown System Version!" End Select If returnType<> 0Then os = os &" [Version: " & .dwMajorVersion& "."& .dwMinorVersion& "."& .dwBuildNumber& "]" End With GetWindowsVersion = os End Function '返回获取本地连接属性的方式 'Vista及Win7下 GetDetailsOf(FolderItem, 2) 获取的值类似于:“Marvell Yukon 88E8056 PCI-E Gigabit Ethernet Controller”,对应XP、2000及2003下的GetDetailsOf(FolderItem, 3) 'Vista及Win7下 GetDetailsOf(FolderItem, 1) 获取的值为本地连接状态,为“网络”时说明正常,对应XP、2000及2003下的GetDetailsOf(FolderItem, 2) Public Function getAdapterStatusType()As Integer Select Case OSName Case "Windows Vista","Windows Server 2008","Windows 7","Windows Server 2008 R2" getAdapterStatusType =2 Case Else getAdapterStatusType =3 End Select End Function '返回获取本地连接属性的方式 'Vista及Win7下 GetDetailsOf(FolderItem, 2) 获取的值类似于:“Marvell Yukon 88E8056 PCI-E Gigabit Ethernet Controller”,对应XP、2000及2003下的GetDetailsOf(FolderItem, 3) 'Vista及Win7下 GetDetailsOf(FolderItem, 1) 获取的值为本地连接状态,为“网络”时说明正常,对应XP、2000及2003下的GetDetailsOf(FolderItem, 2) Public Function getAdapterStatusType()As Integer Select Case OSName Case "Windows Vista","Windows Server 2008","Windows 7","Windows Server 2008 R2" getAdapterStatusType =2 Case Else getAdapterStatusType =3 End Select End Function
Access数据库自身
- office课程播放地址及课程明细
- Excel Word PPT Access VBA等Office技巧学习平台
- 将( .accdb) 文件格式数据库转换为早期版本(.mdb)的文件格式
- 将早期的数据库文件格式(.mdb)转换为 (.accdb) 文件格式
- KB5002984:配置 Jet Red Database Engine 数据库引擎和访问连接引擎以阻止对远程数据库的访问(remote table)
- Access 365 /Access 2019 数据库中哪些函数功能和属性被沙箱模式阻止(如未启动宏时)
- Access Runtime(运行时)最全的下载(2007 2010 2013 2016 2019 Access 365)
Access Activex第三方控件
- Activex控件或Dll 在某些电脑无法正常注册的解决办法(regsvr32注册时卡住)
- office使用部分控件时提示“您没有使用该ActiveX控件许可的问题”的解决方法
- RTF文件(富文本格式)的一些解析
- Access树控件(treeview) 64位Office下出现横向滚动条不会自动定位的解决办法
- Access中国树控件 在win10电脑 节点行间距太小的解决办法
- EXCEL 2019 64位版(Office 2019 64位)早就支持64位Treeview 树控件 ListView列表等64位MSCOMMCTL.OCX控件下载
- VBA或VB6调用WebService(直接Post方式)并解析返回的XML
Access ADP Sql Server等
- 早期PB程序连接Sqlserver出现错误
- MMC 不能打开文件C:/Program Files/Microsoft SQL Server/80/Tools/Binn/SQL Server Enterprise Manager.MSC 可能是由于文件不存在,不是一个MMC控制台,或者用后来的MMC版
- sql server连接不了的解决办法
- localhost与127.0.0.1区别
- Roych的浅谈数据库开发系列(Sql Server)
- sqlserver 自动备份对备份目录没有存取权限的解决办法
- 安装Sql server 2005 express 和SQLServer2005 Express版企业管理器 SQLServer2005_SSMSEE
文章分类
联系我们
联系人: | 王先生 |
---|---|
Email: | 18449932@qq.com |
QQ: | 18449932 |
微博: | officecn01 |