设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 1785|回复: 4
打印 上一主题 下一主题

[API] 求教:如何用ACCESS网络连接测试

[复制链接]
1#
发表于 2012-2-7 20:41:29 | 显示全部楼层
Function Pings(strMachines As String) As Boolean
aMachines = Split(strMachines, ";")
Pings = True
For Each machine In aMachines
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery("select * from Win32_PingStatus where address = '" & machine & "'")
For Each objStatus In objPing
If IsNull(objStatus.StatusCode) Or objStatus.StatusCode <> 0 Then
Debug.Print ("machine " & machine & " is not reachable")
Pings = Pings And False
Else
Pings = Pings And True
End If
Next
Next
End Function


If Pings("计算机1的IP") Then MsgBox "计算机1在线。"
If Pings("计算机2的IP") Then MsgBox "计算机2在线。"
2#
发表于 2012-2-8 11:21:35 | 显示全部楼层
定义变量aMachines 或者去除强制声明
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-5-8 23:45 , Processed in 0.080773 second(s), 24 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表