Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

【转载】获取操作系统版本自定义函数

时 间:2023-10-09 09:17:25
作 者:金宇   ID:43  城市:江阴
摘 要:获取操作系统版本自定义函数GetOperatingSystem()
正 文:

      请将下列函数代码放到Access新增的模块中,然后在窗体中调用函数GetOperatingSystem()就可以获取当前的操作系统版本。

代   :

Public Function GetOperatingSystem()
   Dim localHost       As String
   Dim objWMIService   As Variant
   Dim colOperatingSystems As Variant
   Dim objOperatingSystem As Variant
 
   On Error GoTo Err_Handler
 
   localHost = "." 'Technically could be run against remote computers, if allowed
   Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & localHost & "\root\cimv2")
   Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
 
   For Each objOperatingSystem In colOperatingSystems
       GetOperatingSystem = objOperatingSystem.Caption & " " & objOperatingSystem.Version
     '  Exit Function
   Next
 
  ' Debug.Print GetOperatingSystem
   
   'Determine if operating system is 32-bit or 64-bit
   '-------------------------------------------------
   GetOperatingSystem = GetOperatingSystem & " " & IsWin32OrWin64
   
   'Debug.Print GetOperatingSystem
   
Exit_Handler:
  ' On Error Resume Next
   Exit Function
 
Err_Handler:
   MsgBox "Error " & Err.Number & " in GetOperatingSystem procedure :             " & _
       "@" & Err.Description & "            @", vbCritical, "Program error"
   Resume Exit_Handler

End Function


Access软件网官方交流QQ群 (群号:54525238)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助