VB中使用ping
2005-03-05 09:19
176 查看
Private Sub Command1_Click()
MsgBox GetIP("www.csdn.net")
End Sub
Function GetIP(URL As String) As String
Shell "command.com /c ping " & URL & " -n 1 > c:/ping", vbHide
Dim fn As Integer
fn = FreeFile
RETRY:
Open "c:/ping" For Binary Access Read As #fn
GetIP = Space(FileLen("c:/ping"))
Get #fn, , GetIP
Close #fn
If Len(GetIP) = 0 Then GoTo RETRY
GetIP = Left$(GetIP, InStr(GetIP, "]") - 1)
GetIP = Mid$(GetIP, InStr(GetIP, "[") + 1)
Kill "c:/ping"
End Function
MsgBox GetIP("www.csdn.net")
End Sub
Function GetIP(URL As String) As String
Shell "command.com /c ping " & URL & " -n 1 > c:/ping", vbHide
Dim fn As Integer
fn = FreeFile
RETRY:
Open "c:/ping" For Binary Access Read As #fn
GetIP = Space(FileLen("c:/ping"))
Get #fn, , GetIP
Close #fn
If Len(GetIP) = 0 Then GoTo RETRY
GetIP = Left$(GetIP, InStr(GetIP, "]") - 1)
GetIP = Mid$(GetIP, InStr(GetIP, "[") + 1)
Kill "c:/ping"
End Function
相关文章推荐
- 在vb中使用Iphlpapi.dll获取网络信息 第二章 第十九节 Ping一个IP地址
- 在vb中使用Iphlpapi.dll获取网络信息 第二章 第十九节 Ping一个IP地址
- VB 字符串中使用双引号一法
- [vb]使用vb统计.java的行数
- WINDOWS SCRIPT HOST对象在VB中的使用
- vb上传下载控件Inet-FTP使用大全
- An internal error occurred :不支持请求(使用ping或ipconfig出错),如何重装TCP/IP协议【网络收集】
- PING命令使用的是什么协议?
- 使用VB对word文档进行格式调整
- VB中使用Sockets控件
- VB.NET 章鱼哥 如何在项目中使用外部文字格式
- VB.NET中Caching的使用方法
- [VB.NET]vb.net中使用treenodecollection的add 方法出错
- VB连接ACCESS数据库,使用 LIKE 通配符问题
- 命令行下CMD不能使用ping和ipconfig、tracert等命令不能使用
- ping使用方法
- 无法使用ping或ipconfig命令的解决办法
- VB.NET 使用其他用户启动程序
- 使用VB将ASP代码封装生成DLL文件