vb.net使用ping的简单介绍-成都快上网建站

vb.net使用ping的简单介绍

用VB.NET怎么编一个ping的程序

详见下面代码

十载的上城网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。营销型网站建设的优势是能够根据用户设备显示端的尺寸不同,自动调整上城建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联从事“上城网站设计”,“上城网站推广”以来,每个客户项目都认真落实执行。

Dim m_ping As New System.Net.NetworkInformation.Ping

Dim m_PingReply As System.Net.NetworkInformation.PingReply = m_ping.Send("192.168.1.1", 1000)'设置为自己要ping的ip地址

If m_PingReply.Status = Net.NetworkInformation.IPStatus.Success Then

MsgBox(m_PingReply.RoundtripTime)'返回网络延迟

Else'返回不通的原因

MsgBox(m_PingReply.Status.ToString)

End If

在vb.net里 ping域名得到ip地址 怎么弄

我来说说...i试试看行不行。Option Explicit

Const SYNCHRONIZE = H100000

Const INFINITE = HFFFF

Const WAIT_OBJECT_0 = 0

Const WAIT_TIMEOUT = H102

Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

Private Sub cmdClear_Click()

txtIP.Text = ""

txtNumber.Text = ""

Open "C:\log.txt" For Output As #1

Close #1

txtOutPut.Text = ""

End Sub

Private Sub cmdPing_Click()

Dim ShellX As String

Dim lPid As Long

Dim lHnd As Long

Dim lRet As Long

Dim VarX As String

frmMain.MousePointer = 11

If txtIP.Text "" Then

DoEvents

ShellX = Shell("command.com /c ping -n " txtNumber.Text " " txtIP.Text " C:\log.txt", vbHide)

lPid = ShellX

If lPid 0 Then

lHnd = OpenProcess(SYNCHRONIZE, 0, lPid)

If lHnd 0 Then

lRet = WaitForSingleObject(lHnd, INFINITE)

CloseHandle (lHnd)

End If

Beep

frmMain.MousePointer = 0

Open "C:\log.txt" For Input As #1

txtOutPut.Text = Input(LOF(1), 1)

Close #1

End If

Else

frmMain.MousePointer = 0

VarX = MsgBox("You have not entered an ip address or the number of times you want to ping.", vbCritical, "Error has occured")

End If

End Sub

VB.net 如何ping一个ip地址并获取延迟值?

Dim b As Boolean = My.Computer.Network.Ping("192.168.1.1", 1000) '返回ping结果,true表示通,false表示不通,1000表示1000毫秒内返回结果 

If b = True Then '指定时间内ping通

Shell("cmd /c ping 192.168.1.1  C:\time.txt") '在C盘time.txt文件中保存ping的结果

Else '超时

MsgBox("999") '弹出999提示

End If


当前名称:vb.net使用ping的简单介绍
链接分享:http://kswjz.com/article/doeiogp.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流