设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

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

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

[复制链接]
跳转到指定楼层
1#
发表于 2012-2-7 15:23:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
想做一个内网计算机连接记录程序,不知道怎么实现检测某一IP计算机是否在线。
请教下用什么方法能实现。
比如说怎么检测192.168.1.10这个IP地址当前是否在线。
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 订阅订阅
2#
发表于 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在线。"
3#
发表于 2012-2-8 11:08:23 | 只看该作者
Grant 发表于 2012-2-7 20:41
Function Pings(strMachines As String) As Boolean
aMachines = Split(strMachines, ";")
Pings = Tru ...

提示“aMachines ”未定义
4#
发表于 2012-2-8 11:21:35 | 只看该作者
定义变量aMachines 或者去除强制声明
5#
发表于 2012-2-8 08:26:42 | 只看该作者
学习
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-27 12:37 , Processed in 0.093379 second(s), 28 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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